fns don't support metadata, is it by design?

3 views
Skip to first unread message

Rich Hickey

unread,
Oct 25, 2008, 11:11:59 AM10/25/08
to clo...@googlegroups.com
Begin forwarded message:

cgrand asked:

>
> I forgot to ask you: afaik, fns don't support metadata, is it by
> design?
>


The original and 'pure' notion of metadata was only for value types,
specifically:

(with-meta x new-meta)

should not affect x.

It's becoming obvious that metadata is desired for many of the
reference types. It exists for Vars, and has been requested for
namespaces and fns, and would be useful on Refs and Agents too.

Doing this soundly will require a new variant of with-meta for
reference types (destructive, atomic, alter-meta), and a rejiggering
of the IObj interface hierarchy, splitting the metadata reading from
the writing, so all metadata can still be accessed with meta and ^.

It will also have to be understood that metadata will be for fn
closures only, not IFns in general, as things like maps are already
both IFn and IObj.

Rich

James Reeves

unread,
Oct 25, 2008, 7:07:49 PM10/25/08
to Clojure
On Oct 25, 4:11 pm, Rich Hickey <richhic...@gmail.com> wrote:
> It's becoming obvious that metadata is desired for many of the  
> reference types. It exists for Vars, and has been requested for  
> namespaces and fns, and would be useful on Refs and Agents too.

I can understand namespaces having metadata, as they're very similar
to vars in that they provide a way of naming data. But I don't really
understand why metadata on refs, agents or even functions would be
useful. Have there been threads I've missed that talk about the
advantages of metadata on these types?

- James
Reply all
Reply to author
Forward
0 new messages