curly brace as end of variable symbol?

For the Compleat Fan
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

curly brace as end of variable symbol?

Post by HPW »

From the doc:
Inside the variable name any character is allowed except:
" ' ( ) : , and space. These characters mark the end of a variable symbol.
It happens that I make this mistake:

Code: Select all

>(string"Str1""Str2")
"Str1Str2"
> (string{Str1}{Str2})

invalid function : (string{Str1}{Str2})

> (string {Str1}{Str2})
"Str1Str2"
>  
So would it hurt if a { can get the same as a " ?
(Of cource only a minor problem) ;-)
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

It is a minor inconvenience, because you need a space before the '{' when using as a string limiter, but it lets you use them inside variable names. Note that the { } work different from the normal quotes, they don't do escape character processing and this way you can have quotes " inside strings without escaping them.

Lutz

ps: I am traveling the next few days and will not be as frequent as usual on the discussion board.

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Note that the { } work different from the normal quotes, they don't do escape character processing and this way you can have quotes " inside strings without escaping them.
That's what I like. It allows us neobooker to embed neobook code inside newLISP code without use of any syntax differences. Very nice.

... but it lets you use them inside variable names.
I would never use them there, but maybe a matter of taste. I have no problem when it stays as it is.
Hans-Peter

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Yes well no you mention this, I was sometime ago struggling my head of
with this issue, quiet annoying point though.

{} should simply be independent.. (println{hello})

I vote it should work! :)

Norman.
-- (define? (Cornflakes))

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

I agree with Hans-Peter: keep it the way it is. In addition to Hans-Peter's reasoning, one should never expect something like

Code: Select all

> (println{hello}) 
invalid function : (println{hello})

> (println42)
invalid function : (println42)
to work (regardless of the existing non-parallelism, i.e. one can print something with other types of values slammed up against the 'println'). In short, just type the bleedin' space in there! :-) Cheers!
(λx. x x) (λx. x x)

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

My reasoning was: don't put much constaint on what a legal symbol is. Some people like doing things like defining *2 (times two) etc. So it is accepted that in many instances there has to be a space to separate syntactic elements.

Lutz

Locked