Chouser a écrit :
> On Sun, Feb 22, 2009 at 4:07 PM, jim <[email protected]> wrote:
>
>> In some old code, I did something like:
>>
>> (with-meta (concat [1 3] [8 4])
>> {:tail true}))
>>
>> which now fails. I believe it's because the result of concat is now
>> some kind of reference.
>>
>> Does anyone have any advice on a workaround?
>>
>
> LazySeq extends AFn, so you can't change the metadata once the object
> exists. However, Seq's still accept meta-data, so:
>
> (with-meta (seq (concat [1 3] [8 4]))
> {:tail true})
>
I'm not sure it's desirable to have metadata on seqs (it bit me while
transitionning to lazy) but I have thought of two ways to add withMeta
to a LazySeq:
* to have meta()/withMeta() to force evaluation of the inner seq (and it
begs the question to know whether (= (meta a) (meta (lazy-seq a)))
should be true),
* to have withMeta() to return some kind proxy on the LazySeq object
(cannot this approach also works for regular closures?).
BTW, speaking of regular closures, would it be possible to be able to
set "static" metadata?
eg:
(#^{:meta {:actual :metadata}} fn* [args] body)
(The fn macro could make this prettier.)
Christophe
--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (en)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---