The idea of Javadot is to allow the rich lexical syntax of Lisp and Scheme with the elegance of the dot-notation from the C tradition by simply allowing scope to trump lexical splitting: if foo.bar is in scope as an identifier, then it parses as a variable reference; otherwise it parses as "foo" "." "bar". It's a simple compromise, it's easy to understand, it plays well with lexical scope, and (in an infix language) you can always circumvent it with whitespace. (I don't think it needs to complicate parsing too much, either, since you can do a post-hoc splitting of the lexeme, rather than forcing the lexer to understand scope the way you're forced to with the C typedef ambiguity).
My question is: couldn't you use this idea in an infix language, and generalize it to work for all infix operators? This would allow the use of other common operators such as -, +, *, /, <, and >, all of which I've loved being able to use in identifier names in Scheme, and all of which I also really like being able to use as infix operators.
Subscribe to:
Post Comments (Atom)
20 comments:
Do it! It's easy to imagine how to make it expand properly with #%top and #%variable-reference.
I have this in my toy language. I love it, as it forces you to use white-space around infix operators, which just looks a lot nicer. In fact, in this language you can use any expression as infix operator. F.e. you can construct a binary tree like this: (leaf branch(1) leaf) branch(2) (leaf branch(3) leaf). Here branch is a constructor with 3 arguments.
Jay: I meant it for infix languages, not for Scheme. I mean, Javadot makes sense in the context of Scheme, but once you start having multiple operators, wouldn't you have to write a general-purpose infix parser?
Sjoerd: When you say "forces" do you mean always? My thought was that it's a nicer compromise that you don't have to put whitespace in unless there's an ambiguity with an existing bound variable. This isn't expressible directly in BNF, but you could just lex it as a multi-part lexeme and let a later pass, after scope analysis, decide what to do with it.
Yes, I mean always. It is really helpful to be able to read code without any knowledge of bindings. (Both for the parser and the human reader.)
Don't you hate code where there's no white-space around operators? I certainly do.
Um, then you don't "have this in [your] toy language." You in fact disagree with my post.
The point I picked up from your post was this: "This would allow the use of other common operators such as -, +, *, /, <, and >, all of which I've loved being able to use in identifier names in Scheme, and all of which I also really like being able to use as infix operators."
This is what my toy language has.
But I guess your point was "allowing scope to trump lexical splitting".
Yeah. Maybe I'm being pedantic, but in my head the interesting design question was whether this hybrid approach is a sweet spot.
Certainly languages like C, where scope is required just to parse, tend to be pretty glorious botches. But in this case, you can still parse, you just have to do a little more elucidation at the point of lexical analysis.
Your point about readability is well-taken; readers would have to know that
a-b
could either be an identifier or a binary expression. OTOH, I suspect arithmetic expressions could get pretty unwieldy if you have to have spaces anywhere. But maybe not.
s/anywhere/everywhere/
It's gracefull to see what i was searching for. That's the material which I was searching about. The matter you've highlighted above is surely valueable for anyone to workout. the concept of your article is very true and It will result in a positive way.Casino Royale Suit
whatsapp group link app
whatsapp group link app download
girls whatsapp group
whatsapp girls group
girls whatsapp group link
girl whatsapp group
girl whatsapp group join
girl whatsapp group link
whatsapp girls group link
girls group whatsapp
whatsapp group girls
girl whatsapp group link join
ladies whatsapp group
girls whatsapp number link
Thanks for the info, Check out whatsapp gb official the best mod apk
Fullforms
Fullforms
Fullforms
Fullforms
Fullforms
get these apps and games
netflix mod apk
learn how to unblock someone on facebook
gta san andreas apk
crafting and building
pandora apk
namebiography.com Thanks for this post. Keep it up..
this steps display exhibits HP LAPTOP HARD DISK ERROR is and gives handy solutions to the mistake. Prime reinforcement programming is offered for HP PC framework recuperation.
Thanks for this post. Keep it up..
Also click my blog....
food that is good for your kidneys
Thanks For sharing these post
Messenger Lite
Messenger Lite APK
BeeTalk
BeeTalk APK
Post a Comment