Historical forum-msg-id-130502-edit, Revision 1

Original date:2016-10-28 22:45:17 Edited by: petelomax Subject: Re: Rosetta code: help needed

ed_davis said...
petelomax said...

I also think \n handling in strings is suspect and could do with clarifying/extra tests.
C# has code in the lexer, Python and zkl have a few .replace("\\n", "\n") in the vm|interpreter.
Other solutions seem to be wholly unaware of their existence.

... Which is what I expected.

I was fully expecting Python to work, because of the .replace().
I completely missed the similar code in vm/C (translate) and AST/C (fetch_string_offset).

Let me rephrase:
'\n' is lex'd to 10
Should "\n" be lex'd to {'\\','n'} (as it is now) or {10}?
To me it does not feel right to perform such basic string substitutions at run-time, when they could/should be done at compile-time.
Granted, the "proper" lex will create string constants that need slightly more effort to dump (and slightly less to execute).

I will also say that supporting '\\' but prohibiting "\\" is plain wrong; it should at least be optional, otherwise I cannot factor out common code!

Regards, Pete

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu