Hi Imran,

>>      (de foo (A B)
>>         `(build-some-code)
>>         ~(when (some-condition)
>>            (build-more-code) )
>>         ... )
>
> Interesting. When reading through the docs, it did occur to me at the
> time that read-macros were the only place available in picolisp to
> compute stuff, before runtime. But, I never saw how I could create my
> own read-macro's. I went off looking for functions equivalent to
> (set-read-syntax! ), etc ...
>
> I totally missed what ` does (I guess I'm too used to it meaning
> quasiquote in other lisps).
>
> BTW, is it possible to create your own reader macro's?

Creating reader macros is not built-in in picolisp.  However, you can
write your own reader if you think it's important.  That shouldn't be
that hard.  It's lisp after all.  You'd need such a custom reader also
for example if you exchange sexpr with untrusted sources.

IMHO, reader macros is a cool feature sometimes, but most of the time
the consequences of using them are very annoying.  It breaks tools
(slime) so you have to teach those tools to understand the macros
(dependency to load the right stuff).  It's better to avoid them if you
can.

` in picolisp is like #. in common lisp.  The ~ version slices the read
result in, something like ,@ but for #. reader macro.

As there is no compile-time in picolisp, another possibility to
precompute stuff is at app load time, before http request loop for
example.

If that is not good enough, you can always simulate
macroexpansion/compilation precomputing step and generate picolisp code
into an .l file and then load that.

In picolisp, there is the concept of FEXPRs that is used instead of
macros.  It is more powerful, but the consequence is that the it can't
be split into macroexpansion phase with macroexpansion function, but
requires a different argument evaluation strategy instead that goes
against compilation.

Cheers,

Tomas
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to