Page 1 of 1

curly brace as end of variable symbol?

Posted: Mon Apr 18, 2005 11:09 am
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) ;-)

Posted: Mon Apr 18, 2005 12:42 pm
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.

Posted: Mon Apr 18, 2005 1:02 pm
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.

Posted: Wed Apr 20, 2005 8:30 pm
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.

Posted: Wed Apr 20, 2005 9:36 pm
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!

Posted: Sat Apr 23, 2005 12:38 pm
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