Relative Content

Tag Archive for common-lisp

`values` vs `list` for returning multiple values from Lisp form

What’s the difference between using (values …) versus (list …) (or literally '(one two three …)) to return multiple values from a lambda (or other implicit progn)? Does it create some special glue to multiple-value-bind? Superficially, I can’t see any difference and am curious whether it’s merely a convention for multiple return values.

What about LISP, if anything, makes it easier to implement macro systems?

I’m learning Scheme from the SICP and I’m getting the impression that a big part of what makes Scheme and, even more so, LISP special is the macro system. But, since macros are expanded at compile-time, why don’t people make equivalent macro systems for C/Python/Java/whatever? For example, one could bind the python command to expand-macros | python or whatever. The code would still be portable to people who don’t use the macro system, one would just expand the macros before publishing code. But I don’t know of anything like that except templates in C++/Haskell, which I gather aren’t really the same. What about LISP, if anything, makes it easier to implement macro systems?

What about LISP, if anything, makes it easier to implement macro systems?

I’m learning Scheme from the SICP and I’m getting the impression that a big part of what makes Scheme and, even more so, LISP special is the macro system. But, since macros are expanded at compile-time, why don’t people make equivalent macro systems for C/Python/Java/whatever? For example, one could bind the python command to expand-macros | python or whatever. The code would still be portable to people who don’t use the macro system, one would just expand the macros before publishing code. But I don’t know of anything like that except templates in C++/Haskell, which I gather aren’t really the same. What about LISP, if anything, makes it easier to implement macro systems?

What about LISP, if anything, makes it easier to implement macro systems?

I’m learning Scheme from the SICP and I’m getting the impression that a big part of what makes Scheme and, even more so, LISP special is the macro system. But, since macros are expanded at compile-time, why don’t people make equivalent macro systems for C/Python/Java/whatever? For example, one could bind the python command to expand-macros | python or whatever. The code would still be portable to people who don’t use the macro system, one would just expand the macros before publishing code. But I don’t know of anything like that except templates in C++/Haskell, which I gather aren’t really the same. What about LISP, if anything, makes it easier to implement macro systems?

How do I get a Common Lisp environment object?

The Common Lisp HyperSpec discusses what an environment is. It also discusses environment objects and tells us that their nature is implementation-dependent. Some functions, like MACROEXPAND, take an optional environment object argument.