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> (namespace (keyworld "user" "test"))
; Evaluation aborted.
user> (namespace (keyword "user" "test"))
"user"

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.

I will definitely consider using the clojure printer/reader; that is a
really really good idea, thanks!

I am doing graphics work, so I may have to externalize certain data
(like images and data buffers), but as long as the clojure printer
prints text you have hit upon a really great solution!

Chris

On Dec 21, 12:26 pm, Randall R Schulz <rsch...@sonic.net> wrote:
> 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 a keyword and returns an integer.
> > I will write out a mapping from integer to name to the file.
>
> You should at least consider just using the Clojure printer and reader
> for your serialization / deserialization.
>
> > ...
>
> > Is there a keywords namespace that single colon keywords go into?
>
> Keywords and symbols are the same insofar they they all live in
> namespace. The notation is consistent between the two:
>
> user=> (namespace :foo/bar)
> "foo"
>
> user=> (name :foo/bar)
> "bar"
>
> > Chris
>
> Randall Schulz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to