Weird Lexical Syntax
justine.lol
Weird Lexical Syntax
1–10 of 234 posts
Re: Weird Lexical Syntax
#2Re: Weird Lexical Syntax
#3Re: Weird Lexical Syntax
#4I've done a fair bit of forth and I've not seen c" used. The usual string printing operator is ." .
Re: Weird Lexical Syntax
#5Re: Weird Lexical Syntax
#6I've done a fair bit of forth and I've not seen c" used. The usual string printing operator is ." .
You can easily add new string and comment syntaxes to Forth, though. For example, you can add BCPL-style // comments to end of line with this line of code in, I believe, all standard Forths, though I've only tested it in GForth:
: // 10 word drop ; immediate
Getting it to work in block files requires more work but is still only a few lines of code. The standard word \ does this, and see \ decompiles the GForth implementation as : \
blk @
IF >in @ c/l / 1+ c/l * >in ! EXIT
THEN
source >in ! drop ; immediate
This kind of thing was commonly done for text editor commands, for example; you might define i as a word that reads text until the end of the line and inserts it at the current position in the editor, rather than discarding it like my // above. Among other things, the screen editor in F83 does exactly that.So, as with Perl, PostScript, TeX, m4, and Lisps that support readmacros, you can't lex Forth without executing it.
Re: Weird Lexical Syntax
#7 class Foo\u007b}
and this assert will not trigger: assert
// String literals can have unicode escapes like \u000A!
"Hello World".equals("\u00E4");Re: Weird Lexical Syntax
#8Hmm, it seems to be alive, but based more on behavior than syntax.
Re: Weird Lexical Syntax
#9The comment character in Git commit messages can be a problem when you insist on prepending your commits with some "id" and the id starts with `#`. One suggestion was to allow backslash escapes in commit messages since that makes sense to a computer scientist.[1]
But looking at all of this lexical stuff I wonder if makes-sense-to-computer-scientist is a good goal. They invented the problem of using a uniform delimiter for strings and then had to solve their own problem. Maybe it was hard to use backtick in the 70’s and 80’s, but today[2] you could use backtick to start a string and a single quote to end it.
What do C-like programming languages use single quotes for? To quote characters. Why do you need to quote characters? I’ve never seen a literal character which needed an "end character" marker.
Raw strings would still be useful but you wouldn’t need raw strings just to do a very basic thing like make a string which has typewriter quotes in it.
Of course this was for C-like languages. Don’t even get me started on shell and related languages where basically everything is a string and you have to make a single-quote/double-quote battle plan before doing anything slightly nested.
[1] https://lore.kernel.org/git/vpq3808p40o.fsf@anie.imag.fr/
[2] Notwithstanding us Europeans that use a dead-key keyboard layout where you have to type twice to get one measly backtick (not that I use those)
Re: Weird Lexical Syntax
#10 select'select'select
is a perfectly valid SQL query, at least for Postgres.Languages' approach to whitespace between tokens is all over the place