Hi
‘3D syntax’ came up in the discord recently and Jade Sailor kindly provided an explanation and example:
3d syntax is when a syntax object is programmatically constructed to contain something which doesn't have a source representation
!rkt eval
(parameterize ([current-namespace (make-base-namespace)])
(print
(expand
#'(let-syntax ([f (lambda (stx) #`(quote #,(lambda () 4)))])
(f)))))
r16 APP
#<syntax:trick:4:6 (let-values () (let-values () (quote #<procedure>)))>
The fully expanded version of the program contains a live procedure, not just numbers and lists and identifiers and such. There are occasionally places where something like this is useful, although there are a number of subtle things to be aware of.
(Most notably that the code can't be compiled and stored in a
.zofile and that you can create macros which have weird side effects and generally behave in unexpected ways.)
Also seen at
-
https://stackoverflow.com/questions/17437037/what-is-3d-syntax
-
Racket: [racket-dev] [racket] When does 3D syntax get marshalled?
Perhaps one for the Racket Glossary @sschwarzer ?
Kind Regards,
Stephen ![]()
Credit to @jagen31 for the image
for adding a bit of fun
