curly strings and symbols

Started by HPW, April 01, 2013, 01:46:58 AM

Previous topic - Next topic

HPW

Is this right that curly bracket string and symbols are not allowed to direkt follow each other?

> (setq Test 10)
10
> (setq Test1 (string {Bla}Test{Bla1}))
Blanil
> (setq Test1 (string {Bla} Test {Bla1}))
Bla10Bla1


Or Bug?
Hans-Peter

xytroxon

#1
No...



Without " ' ( ) : , or the space character before { in Test{Bla1}



It is parsed as a legal variable per rule 3.


Quote
1. Syntax of symbol variables and numbers



Source code in newLISP is parsed according to the rules outlined here. When in doubt, verify the behavior of newLISP's internal parser by calling parse without optional arguments.



Symbols for variable names



1. The following rules apply to the naming of symbols used as variables or functions:

Variable symbols may not start with any of the following characters:

# ; " ' ( ) { } . , 0 1 2 3 4 5 6 7 8 9



2. Variable symbols starting with a + or - cannot have a number as the second character.



3. Any character is allowed inside a variable name, except for:

" ' ( ) : , and the space character. These mark the end of a variable symbol.



4. A symbol name starting with [ (left square bracket) and ending with ] (right square bracket) may contain any character except the right square bracket.



5. A symbol name starting with $ (dollar sign) is global. There are several of these symbols already built into newLISP and set and changed internally. This type of global symbol can also be created by the user.



All of the following symbols are legal variable names in newLISP:



myvar

A-name

X34-zz

[* 7 5 ()};]

*111*


-- xytroxon
\"Many computers can print only capital letters, so we shall not use lowercase letters.\"

-- Let\'s Talk Lisp (c) 1976

HPW

#2
Thanks for the explanation.



Regards



Hans-Peter
Hans-Peter

HPW

#3
Of cource it is a bit irritating:



Also from the help:
Quote
Instead of a " (double quote), a { (left curly bracket) and } (right curly bracket) can be used to delimit strings. This is useful when quotation marks need to occur inside strings.



> (setq Test 10)
10
> (setq Test1 (string "Bla"Test"Bla1"))
Bla10Bla1


Since this is valid I had a longer bug-hunt because I thought I could simply replace the double quote.

Or should rule 3 to be changed so that curly brackets would not be allowed in symbols and would act like the double quote?
Hans-Peter