Re: Functions and vars and meta-data

2009-11-27 Thread Stefan Kamphausen
Hi Alex, first of all thank your this exhaustive explanation. I still don't get some things, though, and kindly ask for more enlightenment. On Nov 8, 3:46 am, Alex Osborne a...@meshy.org wrote: So after resolving, it then has a Var object.  A Var, is as it's name suggests, a variable.  It

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen ska2...@googlemail.com writes: On Nov 8, 3:46 am, Alex Osborne a...@meshy.org wrote: As far as the documentation says, Vars can't have metadata: Symbols and collections support metadata, -- http://clojure.org/metadata Symbols, Lists, Vector, Sets and Maps can have metadata

Re: Functions and vars and meta-data

2009-11-27 Thread Stefan Kamphausen
Hi, that have been some really embarrassing typos in my post (typing too fast in too stupid an interface, I think). On Nov 27, 12:52 pm, Alex Osborne a...@meshy.org wrote: Stefan Kamphausen ska2...@googlemail.com writes: On Nov 8, 3:46 am, Alex Osborne a...@meshy.org wrote: As far as the

Re: Functions and vars and meta-data

2009-11-27 Thread Meikel Brandmeyer
Hi, On Nov 27, 10:19 am, Stefan Kamphausen ska2...@googlemail.com wrote: As far as the documentation says, Vars can't have metadata: Symbols and collections support metadata, --http://clojure.org/metadata Symbols, Lists, Vector, Sets and Maps can have metadata --http://clojure.org/reader

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 8:45 AM, Stefan Kamphausen ska2...@googlemail.comwrote: Why? Well because #^ attaches the metadata to the next read form. What's the next read form? It's 'greet. But in fact 'greet is just sugar for (quote greet). So we're actually affixing the metadata to a

Re: Functions and vars and meta-data

2009-11-27 Thread Richard Newman
Maybe this ought to be fixed; i.e., if the reader sees #^{meta} 'foo it applies the metadata to foo first, then quotes it, resulting in the same thing as (quote #^{meta} foo). Why introduce that special case, when you can simply do the second? I don't support the view that it's OK for

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 12:46 PM, Richard Newman holyg...@gmail.com wrote: Maybe this ought to be fixed; i.e., if the reader sees #^{meta} 'foo it applies the metadata to foo first, then quotes it, resulting in the same thing as (quote #^{meta} foo). Why introduce that special case, when

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 1:23 PM, John Harrop jharrop...@gmail.com wrote: On Fri, Nov 27, 2009 at 12:46 PM, Richard Newman holyg...@gmail.comwrote: Maybe this ought to be fixed; i.e., if the reader sees #^{meta} 'foo it applies the metadata to foo first, then quotes it, resulting in the

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen ska2...@googlemail.com writes: I don't think the documentation is *wrong* per se, it just only seems to cover the immutable types. Which is kind of wrong, isn't it? I strongly believe that this should be changed. Indeed. While I understand that the mutating functions

Re: Functions and vars and meta-data

2009-11-27 Thread Stefan Kamphausen
Hi, On Nov 27, 11:06 pm, Alex Osborne a...@meshy.org wrote: A *new* symbol?   I would have thought I'm getting the original symbol again. Yes, one of the differences between symbols and keywords is that symbols are created fresh each time while keywords are interned: (identical? 'foo

Re: Functions and vars and meta-data

2009-11-27 Thread Richard Newman
Whoa! Cool example. This is rather an important point, I think. I mean it's not important, when your only programming with Clojure, which will usally work, and you always have the REPL... But it becomes more important for those, trying to understand. It's about grokking a language's

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen ska2...@googlemail.com writes:   (meta '#^{a 1} greet) To be honest, I think it looks even worse. There is some reader macro which by happy accident works in a certain way together with the other read syntax. No, I don't think it should work. I agree this is ugly and

Re: Functions and vars and meta-data

2009-11-27 Thread DTH
On Nov 27, 5:46 pm, Richard Newman holyg...@gmail.com wrote: I don't support the view that it's OK for programmers to not know what they're doing, which in this case means knowing that 'foo reads as (quote foo). FWIW I *strongly* agree; getting reader macros straight in my head was a *big*

Re: Functions and vars and meta-data

2009-11-08 Thread Stefan Arentz
Hi Alex, Wow! Thank you so much for this excellent explanation! It totally makes sense now :-) S. On 2009-11-07, at 9:46 PM, Alex Osborne wrote: Stefan Arentz wrote: I must admin that I don't fully understand the difference between foo and #'foo. That is probably why I'm making this

Functions and vars and meta-data

2009-11-07 Thread Stefan Arentz
Another one related to my previous question about meta-data. user (defn #^{ :xxx 1} foo [] foo) #'user/foo user (defn #^{ :xxx 2} bar [] bar) #'user/bar I need to do something similar to this: user (map #(:xxx (meta %)) [foo bar]) (nil nil) Basically accessing the meta data of a function of

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz ste...@arentz.ca wrote: But I'm using this in a bigger macro that takes a bunch of functions as a parameter. Is there a way to make this work or should I 'translate' the functions that I take by name with (var foo)? You'll need to translate the

Re: Functions and vars and meta-data

2009-11-07 Thread Stefan Arentz
On 2009-11-07, at 8:28 PM, John Harrop wrote: On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz ste...@arentz.ca wrote: But I'm using this in a bigger macro that takes a bunch of functions as a parameter. Is there a way to make this work or should I 'translate' the functions that I take by

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:34 PM, Stefan Arentz ste...@arentz.ca wrote: On 2009-11-07, at 8:28 PM, John Harrop wrote: On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz ste...@arentz.ca wrote: But I'm using this in a bigger macro that takes a bunch of functions as a parameter. Is there a way

Re: Functions and vars and meta-data

2009-11-07 Thread Alex Osborne
Stefan Arentz wrote: I must admin that I don't fully understand the difference between foo and #'foo. That is probably why I'm making this beginner mistake :-) The difference takes some explanation. So without further ado... Functions and Metadata: in Vivacious Gory Detail