typo in spec2 wiki

91 views
Skip to first unread message

Brent Millare

unread,
Apr 16, 2020, 4:49:54 PM4/16/20
to Clojure Dev
At the spec2 wiki https://github.com/clojure/spec-alpha2/wiki/Schema-and-select

the line:

[::address/street ::address/city ::address/state ::address/zip]


should be


[:address/street :address/city :address/state :address/zip]



note the extraneous colon.


Best,

Brent

Alex Miller

unread,
Apr 16, 2020, 6:20:40 PM4/16/20
to cloju...@googlegroups.com
Either would be correct as an example. The requirement is that it's a qualified keyword referring to a registered spec. The example doesn't declare them so there's no way for it to be "wrong". Both ::address/street and :address/street will create qualified keywords.

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-dev/6cb58e55-68bc-4a45-8ff6-428af333245e%40googlegroups.com.

Brent Millare

unread,
Apr 17, 2020, 8:31:45 AM4/17/20
to Clojure Dev
How does that work? When I type ::address/street I get an error

Syntax error reading source at (REPL:429:18).
Invalid token: ::address/street
*clojure-version*
{:major 1, :minor 10, :incremental 2, :qualifier "master", :interim true}


On Thursday, April 16, 2020 at 6:20:40 PM UTC-4, Alex Miller wrote:
Either would be correct as an example. The requirement is that it's a qualified keyword referring to a registered spec. The example doesn't declare them so there's no way for it to be "wrong". Both ::address/street and :address/street will create qualified keywords.

On Thu, Apr 16, 2020 at 3:49 PM Brent Millare <brent....@gmail.com> wrote:
At the spec2 wiki https://github.com/clojure/spec-alpha2/wiki/Schema-and-select

the line:

[::address/street ::address/city ::address/state ::address/zip]


should be


[:address/street :address/city :address/state :address/zip]



note the extraneous colon.


Best,

Brent

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloju...@googlegroups.com.

Brent Millare

unread,
Apr 17, 2020, 8:57:53 AM4/17/20
to Clojure Dev
Ok, I didn't know that ::address/street is valid to read only if "address" is a valid alias in that current namespace. It wasn't clear that "address" was an alias from the text.

Linus Ericsson

unread,
Apr 17, 2020, 8:58:14 AM4/17/20
to cloju...@googlegroups.com
The error message you see regarding an invalid token is that the symbol "address" is not a namespace alias (like the ones you get with (require '[your.utils-namespace :as util]) or in the ns-declaration in the top of .clj-files. This and similar error messages have been discussed for several years since they originate from deeper in the call stacks and are not very easy to understand if you don't have some understanding of the internals of the Clojure reader. There are several ways to avoid these error messages, one is to use an editor with clj-kondo (Calva has it built in, it's not too hard to easy to enable in emacs/cider).

Also I really encourage you to read the terse but very complete documentation of the reader:


/Linus

To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-dev/f6db93ed-5892-438a-a4b4-a9d07855d788%40googlegroups.com.

Linus Ericsson

unread,
Apr 17, 2020, 8:59:47 AM4/17/20
to cloju...@googlegroups.com
And yes, in that wikipage, the example isn't really complete because there are no mentioning of having to create an alias to have it working.

/Linus

To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-dev/ab4cf7c2-24cb-497c-a96b-76631c8b26d9%40googlegroups.com.

Brent Millare

unread,
Apr 17, 2020, 12:57:59 PM4/17/20
to Clojure Dev
Just a note since I just didn't know about this keyword alias feature and I've read through those docs with a fine tooth comb in the past. This feature is relatively new, at least in the docs https://github.com/clojure/clojure-site/blame/8af4761f966429e0eb1ada9dcc9a7e0cd28de130/content/reference/reader.adoc

That's only 3 years ago, and unless you work with namespace keywords a lot and from composing across different namespaces which also use namespaced keywords, you wouldn't know of the utility of this feature.

Alex Miller

unread,
Apr 17, 2020, 2:46:54 PM4/17/20
to cloju...@googlegroups.com
Autoresolved keywords (double colon with or without aliases) have been part of Clojure since 1.0.

To unsubscribe from this group and stop receiving emails from it, send an email to clojure-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-dev/7b212f67-3f90-4241-acb1-9baced319536%40googlegroups.com.

Brent Millare

unread,
Apr 17, 2020, 6:53:37 PM4/17/20
to Clojure Dev
Wow, I've been using clojure since 2009 and didn't know about that until 11 years later...

Brent Millare

unread,
Apr 17, 2020, 6:54:11 PM4/17/20
to Clojure Dev
just for aliasing
Reply all
Reply to author
Forward
0 new messages