Talk:S-expressions: Difference between revisions

From Rosetta Code
Content added Content deleted
(Symbols and strings)
 
Line 2: Line 2:


To be more generally useful, it's probably better to distinguish between quoted and unquoted strings instead of giving numbers special treatment. <code>0x1, 1d0, 13#4bc, 1.3f, 1_000</code> may or may not be parsed as numbers depending on what the definition of literal numbers is, and can be deferred to a separate step -- as long as the parse remembers that they are not quoted. On the other hand, it's more likely than not that <code>"data"</code> and <code>data</code> mean completely different things, so the parser better remember that information instead of making it optional. --[[User:Ledrug|Ledrug]] 10:48, 16 October 2011 (UTC)
To be more generally useful, it's probably better to distinguish between quoted and unquoted strings instead of giving numbers special treatment. <code>0x1, 1d0, 13#4bc, 1.3f, 1_000</code> may or may not be parsed as numbers depending on what the definition of literal numbers is, and can be deferred to a separate step -- as long as the parse remembers that they are not quoted. On the other hand, it's more likely than not that <code>"data"</code> and <code>data</code> mean completely different things, so the parser better remember that information instead of making it optional. --[[User:Ledrug|Ledrug]] 10:48, 16 October 2011 (UTC)
:you are of course right, i just didn't want to make the task to hard. in languages that don't support symbols, an object would need to be created, if that can be done. otherwise, how can a symbol be represented?
:whether it is useful to distinguish between quoted and unquoted strings also depends on what is done with the input. unless you age writing an interpreter of sorts, the input is just data. and if the language can only handle strings as data, then what good is it to have a special representation for unquoted strings?
:but if anyone wants to distinguish between quoted and unquoted strings and skip numbers instead, they are free to do so--[[User:EMBee|eMBee]] 12:00, 16 October 2011 (UTC)

Revision as of 12:00, 16 October 2011

Symbols and strings

To be more generally useful, it's probably better to distinguish between quoted and unquoted strings instead of giving numbers special treatment. 0x1, 1d0, 13#4bc, 1.3f, 1_000 may or may not be parsed as numbers depending on what the definition of literal numbers is, and can be deferred to a separate step -- as long as the parse remembers that they are not quoted. On the other hand, it's more likely than not that "data" and data mean completely different things, so the parser better remember that information instead of making it optional. --Ledrug 10:48, 16 October 2011 (UTC)

you are of course right, i just didn't want to make the task to hard. in languages that don't support symbols, an object would need to be created, if that can be done. otherwise, how can a symbol be represented?
whether it is useful to distinguish between quoted and unquoted strings also depends on what is done with the input. unless you age writing an interpreter of sorts, the input is just data. and if the language can only handle strings as data, then what good is it to have a special representation for unquoted strings?
but if anyone wants to distinguish between quoted and unquoted strings and skip numbers instead, they are free to do so--eMBee 12:00, 16 October 2011 (UTC)