Yes, unless you wrap it in another macro.
(defmacro a [] (vec (map (fn [x] `(load-string-here ~x)) ["1" "2" "3"
"4"])))
=> (a)
[1 2 3 4]
But it's still pretty useless, unless macros are to replace functions...
Jonathan
On Wed, Jun 22, 2011 at 8:20 AM, Meikel Brandmeyer wrote:
> Hi,
>
> note
Hi,
note that this breaks down as soon as you don't provide a literal string.
And if you provide a literal string, you can provide the form directly
anyway...
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group,
If Clojure was interpreted this behavior would be simple to support.
It seems like you'd have to complicate the compiler for little
benefit.
On Tuesday, June 21, 2011, Jonathan Fischer Friberg wrote:
> Thanks, but I think I'll simply input the let in the string, i.e
>
> (load-string "(let [a (fn
It seems like the following macro would work as well:
(defmacro load-string-here [string] (read-string string))
=> (let [a (fn [] "inside fn")] (load-string-here "(a)"))
"inside fn"
Jonathan
On Tue, Jun 21, 2011 at 12:51 PM, Jonathan Fischer Friberg <
odysso...@gmail.com> wrote:
> Thanks, but
Thanks, but I think I'll simply input the let in the string, i.e
(load-string "(let [a (fn [] "inside fn")] (a))")
But I still think it's odd behavior. I've always thought of eval as equal to
putting that code there.
(eval '(a)) is equal to (a)
Which I think would be much more intuitive.
Jonat
On Mon, Jun 20, 2011 at 7:45 PM, Jonathan Fischer Friberg <
odysso...@gmail.com> wrote:
> I got a very nasty bug from this behavior today
>
> user=> (def a (fn [] "outside a"))
> #'user/a
> user=> (let [a (fn [] "inside a")] (load-string "(a)"))
> "outside a"
> user=> (let [a (fn [] "inside a")] (
On Mon, Jun 20, 2011 at 4:45 PM, Jonathan Fischer Friberg
wrote:
> user=> (def a (fn [] "outside a"))
> #'user/a
> user=> (let [a (fn [] "inside a")] (load-string "(a)"))
> "outside a"
> user=> (let [a (fn [] "inside a")] (eval '(a)))
> "outside a"
>
> Is this really how these functions should beh
I got a very nasty bug from this behavior today
user=> (def a (fn [] "outside a"))
#'user/a
user=> (let [a (fn [] "inside a")] (load-string "(a)"))
"outside a"
user=> (let [a (fn [] "inside a")] (eval '(a)))
"outside a"
Is this really how these functions should behave?
Jonathan
--
You received