Casper, in the example source file you pointed at in the core.logic test
suite, the only times it uses the ::<namespace>/<symbol> syntax is where
<namespace> is an alias for a namespace that has been created by an earlier
:require statement.

In my limited testing in Clojure 1.5.1, that syntax throws an exception if
<namespace> is an existing namespace, or an alias for one, but throws an
exception if it is not an existing namespace.

So in a plain vanilla Clojure 1.5.1 REPL, this works because there is a
namespace clojure.set:

user=> (def s1 #{::clojure.set/foo})
#'user/s1
user=> s1
#{:clojure.set/foo}

but this doesn't work, because there is no namespace clojure.foo:

user=> (def s2 #{::clojure.foo/bar})
RuntimeException Invalid token: ::clojure.foo/bar
clojure.lang.Util.runtimeException (Util.java:219)
RuntimeException Unmatched delimiter: }  clojure.lang.Util.runtimeException
(Util.java:219)
RuntimeException Unmatched delimiter: )  clojure.lang.Util.runtimeException
(Util.java:219)

I do not know if David Nolen is using a supported feature here or an
accident of the Clojure 1.5.1 implementation.

Andy



On Tue, Sep 17, 2013 at 5:01 PM, Dave Ray <dave...@gmail.com> wrote:

> A namespace-qualified keyword has a single colon:
>
> :my-namespace/something
>
> The double-colon is only shorthand for the current namespace:
>
> (in-ns 'my-namespace)
> ::something -> :my-namespace/something
>
> Dave
>
>
>
> On Tue, Sep 17, 2013 at 4:58 PM, Casper Clausen <casp...@gmail.com> wrote:
>
>> The double colon keyword creates a namespaced keyword and is perfectly
>> valid syntax. It's just not used that often :)
>>
>> By default a keyword like ::test resolves to the current namespace like
>> ::current-ns/test, but you can also provide another ns which causes the
>> problem when reading.
>>
>> Have at look at
>> https://github.com/clojure/core.logic/blob/0d1d545f0a81c585c7449aecb5d661120f3da568/src/main/clojure/clojure/core/logic/fd.cljfor
>>  instance.
>>
>> On Wednesday, September 18, 2013 1:05:01 AM UTC+2, daveray wrote:
>>>
>>> Hey,
>>>
>>> You have too many colons:
>>>
>>> user=> (read-string ":l/test")
>>> :l/test
>>>
>>>
>>> Dave
>>>
>>>
>>>
>>> On Tue, Sep 17, 2013 at 4:03 PM, Casper Clausen <cas...@gmail.com>wrote:
>>>
>>>> I am reading a bunch of clojure files using the build-in reader (or
>>>> tools.reader, it has the same problem) and I am running into a problem
>>>> regarding namespaced keywords (is that the right term?) such as ::l/test.
>>>>
>>>> => (read-string "::l/test")
>>>> RuntimeException Invalid token: ::l/test  
>>>> clojure.lang.Util.**runtimeException
>>>> (Util.java:219)
>>>>
>>>> It seems that the reader requires the namespace alias 'l' to exist.
>>>> This is a shame because in most (all?) other respects the reader is able to
>>>> just read in the symbols even if their namespace is not loaded. So in order
>>>> for me to read a file with a namespaced keyword I need to eval at least the
>>>> ns form of the file, which then requires me to eval the ns forms of its
>>>> dependencies (and so on). My code is basically building on the excellent
>>>> codeq analyzer (https://github.com/Datomic/**
>>>> codeq/blob/master/src/datomic/**codeq/analyzers/clj.clj<https://github.com/Datomic/codeq/blob/master/src/datomic/codeq/analyzers/clj.clj>),
>>>> so I am guessing this would have the same problem when running into a
>>>> similar namespaced keyword.
>>>>
>>>> So my question is how do I best get around this?
>>>>
>>>> --
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@googlegroups.com
>>>> Note that posts from new members are moderated - please be patient with
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> clojure+u...@**googlegroups.com
>>>> For more options, visit this group at
>>>> http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en>
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to clojure+u...@**googlegroups.com.
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>
>>>
>>>  --
>> --
>> 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
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> 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
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> --
> 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
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to