On Thu, 2012-06-14 at 00:49 -0700, Rob Harrop wrote:
> I had almost resigned myself to that fact that this would require eval, but
> I wanted to exhaust all macro options first.
As a compromise, you might consider a limited evaluator, such as used by
#=, or a sandboxed evaluator, such as the IRC
Thanks Sean and Alan,
I had noticed the same issue with moving (read-string) inside the macro -
it works great for literals, but then why bother.
I had almost resigned myself to that fact that this would require eval, but
I wanted to exhaust all macro options first.
Thanks,
Rob
On Thursday,
On Wed, Jun 13, 2012 at 8:23 PM, Alan Malloy wrote:
> This can't work as a macro - Sean's suggestion is just as broken as yours,
Ah yes... I got too focused on the original code (with the literal)
instead of trying something more real world...
--
Sean A Corfield -- (904) 302-SEAN
An Architect's
This can't work as a macro - Sean's suggestion is just as broken as yours,
in that it needs the form supplied to be a compile-time literal, because
macros are expanded at compile-time. You can do this at runtime with eval:
something like (defn xr [s] (eval `(fn [] ~(read-string s, though of
On Wed, Jun 13, 2012 at 7:06 PM, Sean Corfield wrote:
> user=> (defmacro xr [f] (list 'fn [] (read-string f)))
Or, if you prefer: (defmacro xr [f] `(fn [] ~(read-string f)))
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingle
On Wed, Jun 13, 2012 at 4:29 PM, Rob Harrop wrote:
> I'm having problems getting read-string and macros to play nicely, a problem
> which can be distilled as below:
Try this:
user=> (defmacro xr [f] (list 'fn [] (read-string f)))
#'user/xr
user=> (apply (xr "(println \"hello\")") [])
hello
nil
u
Doesn't this produce something like:
(fn []
(read-string "(println \"hello\")"))
which would return the list '(println "hello")?
On Wednesday, June 13, 2012 7:29:54 PM UTC-4, Rob Harrop wrote:
>
> Hi,
>
> I have a use case where I'd like to load small forms in String format from
> a database
Hi,
I have a use case where I'd like to load small forms in String format from
a database and wrap them in functions. This is to support some basic
runtime customisation.
I'm having problems getting read-string and macros to play nicely, a
problem which can be distilled as below:
; a simple m