curly brace as end of variable symbol?

Started by HPW, April 18, 2005, 04:09:23 AM

Previous topic - Next topic

HPW

From the doc:
Quote
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:
>(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

#1
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

#2
QuoteNote 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.




Quote... 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

#3
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

#4
I agree with Hans-Peter: keep it the way it is.  In addition to Hans-Peter's reasoning, one should never expect something like
> (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

#5
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