-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Line-expressions #114
base: master
Are you sure you want to change the base?
Line-expressions #114
Conversation
I think I noticed a discrepancy: Right after you say "dots are left-associative," you illustrate that with |
Thanks @rocketnia I fixed the mistake. |
I think that Does this allow unitary |
I've added those two examples to the document. Lexprs ONLY support binary operators. I'll clarify that in an update. |
Oh, you don't intend for dots to be left-associative? If they're meant for field and method lookup as in Java, that would usually make them left-associative (since the thing on the right of the dot isn't even an expression, let alone another dot expression). If you're making them right-associative, what use cases do you have in mind? Meanwhile, I think it's a mistake for |
@rocketnia Re: infix ---- You've made me realize that I always naively interpreted PEMDASFLTR to mean something different than what people actually do. Dumb me. I've changed it to allow @rocketnia Re: dots ---- I was imagining it would work like Remix where the thing on the left of a dot gets to decide what things on the right are valid. It may, for instance, allow another dot expression and look at the first thing. In other words, I'm imaging |
@jeapostrophe A few small questions: Is the strict spacing requirement a question of style (i.e., ensuring that all program have the same shape) or is it important to parsing? Is it important for Do I understand correctly that an There seems to be a kind of ambiguity in parsing I worry about having to use parentheses to get infix operators. For example, I don't think the |
Re: spaces --- I think that all places that require 1 space, could be changed to "at least 1" space, except of course that indentation needs to be well-defined. I don't think that there's any place where less spaces would be okay and where you could have more or less newlines. Re: Re: Re:
is allowed. (I'll add this example.) Second, there's nothing about Lexprs that restrict the Re: ambiguity of Re: infix --- You are correct that I intended to get Re: infix and indentation --- You are not correct. A group (the inside of parens) is a series of units separated by spaces---thus newlines are not included. If you put a newline in, then you have a mismatched |
Ah, I see. The Even as a fan of s-expressions, I find the dot notation particularly compelling for things that are like namespaces. Specifically, I think situations come up where a big section of code uses "variables" that aren't quite like the usual variables in the language. Often this means every variable (say, Extrapolating from that, I'd say chained dots are particularly helpful for namespace-like things that are looked up from other namespace-like things. Essentially, the expression I think a natural way to look at this situation is that the result of a macro call (in this case, the result of a namespace lookup) isn't always an expression; it's sometimes another macro (in this case, namespace) that can be called again. I've explored this approach before in Penknife, a language I wrte where a macro result was a "fork" object that could be converted into an expression or called as a macro. But in the context of Racket, macros are (more or less) s-expression-to-s-expression transformers, and the thing in the macro position is (almost?) never a compound expression like |
@jeapostrophe The line continuations (the slash line followers) in The upshot (I think) is that the newline+indentation after
whereas the newline+indentation+bar after the colon is required. I don't have a better way to describe this than to say it feels odd to me. |
@97jaz I agree that I used |
@jeapostrophe To refresh my memory and improve my understanding of Lexprs, I tried converting "demo.sap" to Lexprs: https://gist.github.com/mflatt/aa09fd2ac9e445bbddd99f6243a21458 Does that look like the kind of syntax that would you choose? Search As a general observation, my naive expectations were often defeated by the way that a
and expect it to be like
but it parses as
|
Your question on top about In general, I assume that people won't use 1: I'd expect
or
19 vs 26: I like 19. 48: You can't break it across lines inside of 55 & 62: I don't understand what these things are supposed to be doing, but it is an application of the 71: I thought that structs would be written something like:
101: Ya, there's no way to end most lines without a newline 104: I like that usage of
120: Ya, you've got two 127:
where each item to the left of 148: I think I'd write it like:
153: No, for the same reason as above, and I'm okay with changing that. I might want to do something like enforcing Haskell style 162: I think I'd use
(This revealed an error in the code, which I've updated.) |
Ah, I missed that a line continues after a last Yes, I used I updated the Gist with my improved understanding of the right style. |
I'll add that to the description. It didn't say it, except for |
I updated the examples slightly, replacing most |
Here's yet another proposal for syntax. This one comes with a real parser and a full test suite of examples that are in the write-up. I really like this one a lot.