Skip to main content
Filter by
Sorted by
Tagged with
2 votes
2 answers
112 views

I'm trying to wrap my head around macros in Common Lisp, and I have this piece of code to create synth-definitions with the cl-collider client for the supercollider sound synthesis language: (defmacro ...
kflak's user avatar
  • 89
0 votes
3 answers
187 views

So my idea is to reduce the amount of calls to an object instance, when it is clearly the only one in scope. Here's a code example: (defun read-plist (plist) (let ((plist-reader (make-instance '...
Alteration Dream's user avatar
1 vote
1 answer
106 views

I'm writing an application (a simple game) using cl-sdl2. cl-sdl2 includes a macro called WITH-EVENT-LOOP that can be used to start the SDL application with some event handlers. Currently I use the ...
Dan Passaro's user avatar
  • 4,436
1 vote
3 answers
86 views

I am attempting to answer the following exercise. Write a macro function OUR-IF that translates the following macro calls. (our-if a then b) translates to (cond (a b)) (our-if a then b else c) ...
preferred_anon's user avatar
0 votes
2 answers
170 views

I am using SBCL, Slime, and Emacs to develop in Common Lisp. I have this function: (defun build-cond-action-pairs (&rest var) (labels ((aux (xs-left accu) (cond ((null (cddr xs-left)...
Pedro Delfino's user avatar
0 votes
2 answers
142 views

I am trying to learn Common Lisp with the book Common Lisp: A gentle introduction to Symbolic Computation. In addition, I am using SBCL, Emacs, and Slime. In the last chapter, on Macros, the author ...
Pedro Delfino's user avatar
0 votes
1 answer
146 views

I've been using Guile for about a year, but am fairly inexperienced in using macros in Scheme. Although I have got some more complicated examples to work satisfactorily, I'm getting stuck on what (to ...
Phil's user avatar
  • 662
3 votes
1 answer
896 views

I got this answer https://stackoverflow.com/a/70318991 about writing a simple macro that records the time at macro expansion time, and then always returns that time. #lang racket (begin-for-syntax (...
Alex028502's user avatar
  • 3,854
1 vote
1 answer
282 views

I did this: #lang racket (define-syntax-rule (macro-expansion-seconds) (current-seconds)) which does this > (macro-expansion-seconds) 1639244531 > (macro-expansion-seconds) 1639244532 > (...
Alex028502's user avatar
  • 3,854
2 votes
1 answer
161 views

Some Lisp implementations (i) expand macros once and save the result for reuse; (ii) others reexpand the macro at each macro call. Some implementations (iii) even attempt to expand macro calls in ...
Pedro Delfino's user avatar
0 votes
1 answer
132 views

I am trying to learn Common Lisp with the book Common Lisp: A gentle introduction to Symbolic Computation. In addition, I am using SBCL, Emacs, and Slime. In chapter 14, the last one, the author ...
Pedro Delfino's user avatar
0 votes
1 answer
336 views

I am trying to learn Common Lisp with the book Common Lisp: A gentle introduction to Symbolic Computation. In addition, I am using SBCL, Emacs, and Slime. In chapter 14, the last one, the author ...
Pedro Delfino's user avatar
1 vote
1 answer
218 views

I am working on a complicated macro and have run into a roadblock. (defmacro for-each-hashtable-band (body vars on &optional counter name) `(block o (with-hash-table-iterator (next-entry ,...
Akasha's user avatar
  • 245
2 votes
1 answer
364 views

I am trying to learn Common Lisp with the book Common Lisp: A gentle introduction to Symbolic Computation. In addition, I am using SBCL, Emacs and Slime. In chapter 7, the author suggests the ...
Pedro Delfino's user avatar
0 votes
1 answer
96 views

I'm trying to create a macro (bar) that should be used like this: (let ((my-var "foo")) (bar ("some") :buzz (lambda () (format t "~a~%" my-var)))) The macro ...
Manfred's user avatar
  • 517
0 votes
1 answer
151 views

So using common lisp, I want to be able to do something of the sorts of: (defmacro foo (count &rest someExpression) `(do ((,count 0 (+ ,count 1))) ((= ,count 5) T) `(...
JustAFellowCoder's user avatar
1 vote
3 answers
277 views

I'm learning (common) Lisp, and as exercise, I want to implement 'xond', a cond macro, that transform this silly example: (xond (= n 1) (setq x 2) (= n 2) (setq x 1)) into a if-else chain: (if (= n 1)...
user avatar
3 votes
2 answers
369 views

I've had this question more than once before. Generic Question Is it possible to transparently locally shadow a function f with a wrapper of it with the same name f? I.e., how to locally have (f ...
Alberto's user avatar
  • 605
1 vote
1 answer
1k views

There were similar question but not with syntax macros, I though that the difference is that one macro can't see the other like letrec and let with functions. But this works the same with letrec-...
jcubic's user avatar
  • 67.1k
1 vote
1 answer
124 views

I started learning lisps and am currently working on Macros for school. I created a simple macro called "-=" in a txt file called decrement.txt (defmacro -= (numericValue decrementValue) (list '...
only_chio's user avatar
0 votes
1 answer
220 views

For some code I was working I've needed to handle 'x inside macro. What is standard way of handling those values? I have code like this: (define (quoted-symbol? x) (and (pair? x) (eq? (car x) '...
jcubic's user avatar
  • 67.1k
2 votes
2 answers
308 views

I have created a macro in clojure (ns macro-question.map) (defmacro lookup [key] (list get (apply hash-map (range 1 5)) key)) in the clojure repl it works as expected $ clj Clojure 1.9.0 user=> (...
Alex028502's user avatar
  • 3,854
2 votes
3 answers
1k views

I'm trying to write a macro in Common Lisp that takes any number of expressions and builds a list containing each expression followed by its evaluation in a single line. For example, if I name my ...
2abysses's user avatar
  • 101
2 votes
2 answers
101 views

I'm trying to write a macro that defines some helpers for struct-of-arrays data structure (based on this snippet). Inside that macro I define another macro that helps with traversing all of the slot ...
Andrew Kravchuk's user avatar
5 votes
1 answer
651 views

Here is simplified example from book On Lisp by Paul Graham (scheme like syntax). (define-macro (bar) (let ((x 10) (y '(1 2 3)) (z 'foo)) `(list ,x `(,',z ,,@y)))) I know how ,,@y should work ...
jcubic's user avatar
  • 67.1k
1 vote
1 answer
370 views

I need to write the lisp macro in scheme (please on hygienic macros and syntax-rules etc) that will have function call and Alist as argument I want function and macro that call that function to have ...
jcubic's user avatar
  • 67.1k
0 votes
1 answer
316 views

I have general question how should I go about and create proper macroexpand function or macro. This is definition of my macro in LIPS interpreter (you can test it here https://jcubic.github.io/lips/) ...
jcubic's user avatar
  • 67.1k
3 votes
3 answers
290 views

So I want to know if there is standard way of having code like this: (let ((x 10)) (define (add10 a) (+ x a))) I know about: (define add10 (let ((x 10)) (lambda (a) (+ x a))))...
jcubic's user avatar
  • 67.1k
0 votes
1 answer
349 views

I have LISP written in JavaScript (https://jcubic.github.io/lips/ with online demo where you can try it) and I have macro like this: (define-macro (globalize symbol) (let ((obj (--> (. lips 'env)...
jcubic's user avatar
  • 67.1k
1 vote
0 answers
120 views

I have problem with macros in my lisp interpreter writtein in JavaScript. the problem is in this code: (define log (. console "log")) (define (alist->object alist) "(alist->object alist) ...
jcubic's user avatar
  • 67.1k
2 votes
1 answer
222 views

I have macro that I've written in 2010, it was for managing structures like in Common Lips using Alists (here is whole file including functions https://jcubic.pl/struct.txt). (define-macro (defstruct ...
jcubic's user avatar
  • 67.1k
0 votes
1 answer
184 views

I wonder if it is possible to dynamically build COND clauses from a loop like (pseudo code): (defvar current-state 1) (defmacro mymacro () (cond `(loop (state . callback) in possible-states ...
SmartyLisp's user avatar
0 votes
2 answers
250 views

I can use memfn to create a clojure function that invokes a java function. (macroexpand '(memfn startsWith prefix)) => (fn* ([target2780 prefix] (. target2780 (startsWith prefix)))) ((memfn ...
John Dorian's user avatar
  • 1,904
1 vote
2 answers
252 views

I am trying to evaluate an infixed expression in a string. Some sample data to evaluate my code against: (def data {:Location "US-NY-Location1" :Priority 3}) (def qual "(Location = \"US\"...
pvik's user avatar
  • 105
0 votes
1 answer
82 views

(defmacro get-color [color-name] `@(thi.ng.color.core/as-int32 (var-get (resolve (symbol "thi.ng.color.core" (str '~color-name)))))) I like to avoid using ...
HappyFace's user avatar
  • 4,193
3 votes
2 answers
286 views

In Common Lisp, how to define a “meta-macro” which takes as argument a list of macros (and other arguments) and composes these macros to produce the desired code. The problem is equivalent to writing ...
Michaël Le Barbier's user avatar
2 votes
1 answer
121 views

I'm currently learning lisp with Graham's book “ANSI Common Lisp” and as an exercise I am writing Julian-day based calendar calculations. As you know, the Easter Sunday changes from year to year and ...
Michaël Le Barbier's user avatar
4 votes
2 answers
2k views

Currently learning common lisp, following Peter Seibel's Practical Common Lisp (i'm at chapter 11, about collections), i have difficulties to understand how setf works behind the hood. Considering ...
aluriak's user avatar
  • 5,957
0 votes
1 answer
68 views

I have: (defmacro assign (name value) (format t "assigning ~A to ~A~%" `,name `,value)) (defun opcode-call (&rest args) (mapcar (lambda (arg) (if (stringp arg) ...
Capstone's user avatar
  • 2,292
1 vote
0 answers
49 views

I am attempting to modify the python major mode to work slightly differently. Specifically, I would like to change python-indent-region. I believe I have figured out what change I need to make (it ...
Kurt Wheeler's user avatar
1 vote
2 answers
284 views

I have read section 6.7 of LOL a few times now, and I still can't wrap my mind around the following. Bindings that were previously closed to outside code are now wide open for us to tinker with, ...
Todd's user avatar
  • 495
2 votes
2 answers
912 views

I want this code : (setq name "foobar") (defun (intern name) ()) do the same thing as : (defun foobar ()) I have tried this (from This question): (defmacro make-my-function (name) (list 'defun (...
Bapt's user avatar
  • 21
4 votes
2 answers
725 views

Lisp-rookie here. My goal is to define a macro that will make the keys of a dotted alist available as variables to access the corresponding values, hence the name »let-dotted-alist«. So what I want ...
Phylax's user avatar
  • 329
0 votes
1 answer
191 views

How can I conditionally remove a let-binding in a defun created in a lisp macro? Here, I want to remove the first let-bound variable from the resulting function, but am running into a problem where I ...
Rorschach's user avatar
  • 32.7k
0 votes
1 answer
220 views

How can I substitute a symbol name into a function created in a macro? I think I am missing something obvious here. For example, I am trying to make a macro that defines some variables and functions ...
Rorschach's user avatar
  • 32.7k
6 votes
4 answers
2k views

How do I modify the :arglist attribute for a clojure fn or macro? (defn tripler ^{:arglists ([b])} [a] (* 3 a)) (defn ^{:arglists ([b])} quadrupler [a] (* 4 a)) % (meta #'tripler) => {:...
Stephen Cagle's user avatar