Re: Functions and vars and meta-data

2009-11-27 Thread DTH
On Nov 27, 5:46 pm, Richard Newman 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* help in macro wri

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen 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 unintuitive and I wo

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'

Re: Functions and vars and meta-data

2009-11-27 Thread Stefan Kamphausen
Hi, On Nov 27, 11:06 pm, "Alex Osborne" 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 'foo) ;

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen 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 will not apply to

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 1:23 PM, John Harrop wrote: > On Fri, Nov 27, 2009 at 12:46 PM, Richard Newman 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}

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 12:46 PM, Richard Newman 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 you can sim

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 p

Re: Functions and vars and meta-data

2009-11-27 Thread John Harrop
On Fri, Nov 27, 2009 at 8:45 AM, Stefan Kamphausen wrote: > > 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 > > list containing t

Re: Functions and vars and meta-data

2009-11-27 Thread Meikel Brandmeyer
Hi, On Nov 27, 2:45 pm, Stefan Kamphausen wrote: > A *new* symbol?   I would have thought I'm getting the original symbol > again. If you get back the original symbol back, it can't carry metadata... > Definitely, and I don't like the distinction too much either. But it makes sense. A Var rep

Re: Functions and vars and meta-data

2009-11-27 Thread Meikel Brandmeyer
Hi, On Nov 27, 10:19 am, Stefan Kamphausen 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 > > I tried t

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" wrote: > Stefan Kamphausen writes: > > On Nov 8, 3:46 am, Alex Osborne wrote: > > As far as the documentation says, Vars can't have metadata:

Re: Functions and vars and meta-data

2009-11-27 Thread Alex Osborne
Stefan Kamphausen writes: > On Nov 8, 3:46 am, Alex Osborne 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/re

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 wrote: > So after resolving, it then has a Var object.  A Var, is as it's > name suggests, a variable.  It consist of a nam

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

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 ==

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:34 PM, Stefan Arentz wrote: > On 2009-11-07, at 8:28 PM, John Harrop wrote: > > > On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz > > 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 sho

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 > 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 (va

Re: Functions and vars and meta-data

2009-11-07 Thread John Harrop
On Sat, Nov 7, 2009 at 8:04 PM, Stefan Arentz 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 symbols into va

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 functio