The gensym function can be very useful in macros. It can be effectively implemented by creating symbols that are not added to symlist, so such symbols can be removed by the garbage collector and may not have a string representation.
This is how you can change the implementation of the for macro from 'scripts/macros.fe' using gensym:
(= for (mac (item lst . body)
(let for-iter (gensym))
(list 'do
(list 'let for-iter lst)
(list 'while for-iter
(list 'let item (list 'car for-iter))
(list '= for-iter (list 'cdr for-iter))
(cons 'do body)
)
)
))
It is assumed that for-iter should not be visible when body is called. I'm implemented it in my fork.
The
gensymfunction can be very useful in macros. It can be effectively implemented by creating symbols that are not added tosymlist, so such symbols can be removed by the garbage collector and may not have a string representation.This is how you can change the implementation of the
formacro from 'scripts/macros.fe' usinggensym:It is assumed that
for-itershould not be visible whenbodyis called. I'm implemented it in my fork.