Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Rich Hickey
On Dec 22, 11:57 am, Chouser wrote: > On Mon, Dec 22, 2008 at 11:31 AM, Stuart Sierra > > wrote: > > > On Dec 22, 11:05 am, Rich Hickey wrote: > >> But I think there is a tendency to bring presumptions from CL's > >> symbols/packages/interning, many of which do not apply. > > > Sounds like a

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Chouser
On Mon, Dec 22, 2008 at 11:31 AM, Stuart Sierra wrote: > > On Dec 22, 11:05 am, Rich Hickey wrote: >> But I think there is a tendency to bring presumptions from CL's >> symbols/packages/interning, many of which do not apply. > > Sounds like a good FAQ, or another entry in http://clojure.org/lisp

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Stuart Sierra
On Dec 22, 11:05 am, Rich Hickey wrote: > But I think there is a tendency to bring presumptions from CL's > symbols/packages/interning, many of which do not apply. Sounds like a good FAQ, or another entry in http://clojure.org/lisps If I may: "Unlike Common Lisp, symbols and keywords are just i

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Rich Hickey
On Dec 22, 10:43 am, Randall R Schulz wrote: > On Monday 22 December 2008 07:23, Rich Hickey wrote: > > > ... > > > This conversation is way off track. > > > Symbols and keywords are not 'in' namespaces, they are not interned > > in namespaces, there are not lists of, e.g. keywords in a particu

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 07:23, Rich Hickey wrote: > ... > > This conversation is way off track. > > Symbols and keywords are not 'in' namespaces, they are not interned > in namespaces, there are not lists of, e.g. keywords in a particular > namespace. Then the term "namespace" is rather poorly

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Rich Hickey
On Dec 22, 9:01 am, Randall R Schulz wrote: > On Monday 22 December 2008 05:51, Mark Volkmann wrote: > > > On Sun, Dec 21, 2008 at 2:30 PM, Randall R Schulz > wrote: > > > On Sunday 21 December 2008 11:33, chris wrote: > > >> ... > > > >> That answers my question. Don't use a namespace, and t

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Randall R Schulz
On Monday 22 December 2008 05:51, Mark Volkmann wrote: > On Sun, Dec 21, 2008 at 2:30 PM, Randall R Schulz wrote: > > On Sunday 21 December 2008 11:33, chris wrote: > >> ... > >> > >> That answers my question. Don't use a namespace, and the keyword > >> is global. Pass in a namespace, and the

Re: Behavior of equals (==) w/r/t keywords

2008-12-22 Thread Mark Volkmann
On Sun, Dec 21, 2008 at 2:30 PM, Randall R Schulz wrote: > > On Sunday 21 December 2008 11:33, chris wrote: >> ... >> >> That answers my question. Don't use a namespace, and the keyword is >> global. Pass in a namespace, and the keyword is in that namespace. > > Yes, the default namespace for k

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 11:33, chris wrote: > ... > > That answers my question. Don't use a namespace, and the keyword is > global. Pass in a namespace, and the keyword is in that namespace. Yes, the default namespace for keywords is different than for symbols, which is why the ::keyword fo

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
user> (namespace :test) nil So it doesn't live in a namespace. But it is a distinct entity; a comparable value. user> (= :test :test) true user> (= :test :bar) false user> (keyword "test") :test user> (namespace (keyword "test")) nil user> (namespace (keyword "test" "user")) "test" user> (name

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 10:18, chris wrote: > Right, waking up a bit. > > I would like, at some point, to serialize a bunch of structures to a > byte stream. > > They are the mapped structs (struct :data1 :data2). > > Lets say I would like to do this generically, I need a function that > takes

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
Right, waking up a bit. I would like, at some point, to serialize a bunch of structures to a byte stream. They are the mapped structs (struct :data1 :data2). Lets say I would like to do this generically, I need a function that takes a keyword and returns an integer. I will write out a mapping f

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread Randall R Schulz
On Sunday 21 December 2008 09:33, chris wrote: > This is not what I would expect: > > user> (== :test :test) > false user=> (doc ==) - clojure.core/== ([x] [x y] [x y & more]) Returns non-nil if nums all have the same value, otherwise false To be clear: == is for numer

Re: Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
Ah, user> (= :float :float) true Chris On Dec 21, 10:33 am, chris wrote: > This is not what I would expect: > > user> (== :test :test) > false > > I am trying to use keywords as enumerations to texture types.  I want > to know if two textures are comparable, thus I would expect > (== :rgba :rgb

Behavior of equals (==) w/r/t keywords

2008-12-21 Thread chris
This is not what I would expect: user> (== :test :test) false I am trying to use keywords as enumerations to texture types. I want to know if two textures are comparable, thus I would expect (== :rgba :rgba) to return true. I may have missed something, but it seems like Rich did away with the