No names with trailing % allowed but with a leading one?

0 views
Skip to first unread message

Stefan Kamphausen

unread,
Nov 17, 2009, 9:30:42 AM11/17/09
to Clojure
Hi,

during some examinations about the broken REPL with current Slime I
found that I can't create names with a trailing %:

Clojure 1.1.0-alpha-SNAPSHOT
user=> (def %thisworks 11)
#'user/%thisworks
user=> %thisworks
11
user=> (def %thisdoesnt% 22)
java.lang.Exception: Too many arguments to def (NO_SOURCE_FILE:3)
user=>

According to http://clojure.org/reader : "Symbols begin with a non-
numeric character and can contain alphanumeric characters and *, +, !,
-, _, and ? (other characters will be allowed eventually, but not all
macro characters have been determined)"

So, am I right, that "non-numeric character" for the first char
includes the percent-sign whereas the explicit list for all following
characters doesn't.

Rather peculiar, I think. Not?

Kind regards,
Stefan

PS: The background of this is, that Slime is sending a "%CURSOR-MARKER
%" down the line.

Sean Devlin

unread,
Nov 17, 2009, 1:46:28 PM11/17/09
to Clojure
I *THINK* what is meant by the "non-numeric" is anything that matches

#"[a-zA-z]"

Just my $.02

Sean

On Nov 17, 9:30 am, Stefan Kamphausen <ska2...@googlemail.com> wrote:
> Hi,
>
> during some examinations about the broken REPL with current Slime I
> found that I can't create names with a trailing %:
>
> Clojure 1.1.0-alpha-SNAPSHOT
> user=> (def %thisworks 11)
> #'user/%thisworks
> user=> %thisworks
> 11
> user=> (def %thisdoesnt% 22)
> java.lang.Exception: Too many arguments to def (NO_SOURCE_FILE:3)
> user=>
>
> According tohttp://clojure.org/reader: "Symbols begin with a non-

John Harrop

unread,
Nov 17, 2009, 2:12:45 PM11/17/09
to clo...@googlegroups.com
On Tue, Nov 17, 2009 at 1:46 PM, Sean Devlin <francoi...@gmail.com> wrote:
I *THINK* what is meant by the "non-numeric" is anything that matches

#"[a-zA-z]"

Nah, it'll be anything that's allowed elsewhere AND is not a digit.

Stefan Kamphausen

unread,
Nov 17, 2009, 2:17:17 PM11/17/09
to Clojure
Hi,

On Nov 17, 8:12 pm, John Harrop <jharrop...@gmail.com> wrote:
> On Tue, Nov 17, 2009 at 1:46 PM, Sean Devlin <francoisdev...@gmail.com>wrote:
>
> > I *THINK* what is meant by the "non-numeric" is anything that matches
>
> > #"[a-zA-z]"
>
> Nah, it'll be anything that's allowed elsewhere AND is not a digit.

Does that mean, the % as the first char should not be allowed, whereas
at it is in the Version I use (did that change in branch new, BTW?).

And, wouldn't it be nice to get a clearer error-message? :-)

Best regards,
Stefan

John Harrop

unread,
Nov 17, 2009, 2:40:03 PM11/17/09
to clo...@googlegroups.com
On Tue, Nov 17, 2009 at 2:17 PM, Stefan Kamphausen <ska...@googlemail.com> wrote:
Hi,

On Nov 17, 8:12 pm, John Harrop <jharrop...@gmail.com> wrote:
> On Tue, Nov 17, 2009 at 1:46 PM, Sean Devlin <francoisdev...@gmail.com>wrote:
>
> > I *THINK* what is meant by the "non-numeric" is anything that matches
>
> > #"[a-zA-z]"
>
> Nah, it'll be anything that's allowed elsewhere AND is not a digit.

Does that mean, the % as the first char should not be allowed, whereas
at it is in the Version I use (did that change in branch new, BTW?).

The docs say that letters and *, +, !, -, _, and ? should work anywhere, and letters, numbers, and  *, +, !, -, _, and ? elsewhere than the first character, while making no guarantees about most other characters and specifically indicating that / and . will NOT work. (And delimiters -- (, ), {, }, [, and ] -- won't work, nor will whitespace (including commas), since they act as token separators.)

In practice, most other characters seem to work, but characters used in reader macros (#, %, ;, ', `, ~, @, etc.) may not. It is rather odd that % acts up outside of the #() reader macro though. 

And, wouldn't it be nice to get a clearer error-message? :-)

Wouldn't it always?

Stefan Kamphausen

unread,
Nov 17, 2009, 2:57:46 PM11/17/09
to Clojure
Hi John,

On Nov 17, 8:40 pm, John Harrop <jharrop...@gmail.com> wrote:
> The docs say that letters and *, +, !, -, _, and ? should work anywhere,

do you read it that way? I think the doc (if you are referring to
http://clojure.org/reader) are a little vague here: "Symbols begin
with a non-numeric character".

> and
> letters, numbers, and  *, +, !, -, _, and ? elsewhere than the first
> character, while making no guarantees about most other characters

I understood that other characters weren't allowed at all. So I
wondered that I could create a variable-name starting with a %. But
the vagueness about the first char jumped right in, since it allows
the % there.

But then, it just feels like an accident and not like purpose, so I
thought, I'd better ask.

>> And, wouldn't it be nice to get a clearer error-message? :-)
>
> Wouldn't it always?

Sure, that's the reason for that :-) up there.

Best regards,
Stefan

Meikel Brandmeyer

unread,
Nov 17, 2009, 2:24:27 PM11/17/09
to clo...@googlegroups.com
Hi,

Am 17.11.2009 um 19:46 schrieb Sean Devlin:

> I *THINK* what is meant by the "non-numeric" is anything that matches
>
> #"[a-zA-z]"

Along with !,+,*,.,?,...

Sincerely
Meikel

Reply all
Reply to author
Forward
0 new messages