3 ms·
> If you are claiming that "compile-time evaluation" (macros) in Racket works with lists (i.e. the input to a macro is a list, and the output from a macro is a
by samatman 2y ago
> If you are claiming that "compile-time evaluation" (macros) in Racket works with lists (i.e. the input to a macro is a list, and the output from a macro is a list), that is false. It works with syntax objects
This is a distinction without a difference. From your quote:
> A syntax object contains symbols, lists, and constant values (such as numbers) that essentially correspond to the quoted form of the expression.
If it's important to you that it's actually atoms and lists, well, some of us generalize better than others. But calling it false? Lame. As is your feigned confusion.
> A macro can do anything
Syntax and side effects. Take your pick.
> It seems to me that Racket's macros are strictly a super-set of Zig's comptime.
The difference here is that you have experience with one of these systems. I have experience with both. I doubt further interactions would be informative for either of us.
- noelwelsh 2y agoIf you want to take this as a confrontation instead of a discussion I agree it's not worthwhile continuing. My confusion is real. I don't get your point. How does "they do what Lisp-style compile-time evaluation has always done: they build up lists" delineate Racket's capabilities compared to Zig? It's false on the surface (syntax objects are not lists) and it's false at a deeper level (macros can do anything). Even if it were true, I don't understand the significance of using lists, or not, as a representation of a program. I know, from experience, you can put any value into a syntax object / list so ¯\_(ツ)_/¯ I don't understand what "Zig comptime is part of the compiling process" means in contrast to Racket. How does this differentiate between the two? Macros provide an API to the compiler, are part of the compiling process, and you can insert, e.g, assembly code generated by a macro into a Racket program (I did this a long time ago). > Syntax and side effects. Take your pick. What does this mean? "Take your pick" implies xor, but you use and. Is this a typo? If you doubt that macros can do arbitrary side-effects, put the following in a file (e.g. "comptime.rkt") and from Racket call (require "comptime.rkt") #lang racket (define-syntax when (lambda (stx) (begin (println "Compile-time") (datum->syntax stx '(println "b"))))) (begin (println "a") (when) (println "c")) You'll see the output "Compile-time" "a" "b" "c" The println in the macro when runs before the code in the begin form evaluates. I.e. it is running at compile-time.
- samatman 2y ago> I don't understand what "Zig comptime is part of the compiling process" means in contrast to Racket. You've made that clear, yes.