The obligatory permalink and latest draft
Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
September 21 Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
September 22 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Quirin Schroll | I recommend that you put it through Grammarly prior to Mike getting it, it'll lessen his workload. I.e. ``excpetion`` Otherwise it is looking pretty good, and good job on doing the implementation! |
September 21 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Richard (Rikki) Andrew Cattermole | On Saturday, 21 September 2024 at 13:29:05 UTC, Richard (Rikki) Andrew Cattermole wrote: >I recommend that you put it through Grammarly prior to Mike getting it, it'll lessen his workload. I.e. Otherwise it is looking pretty good, and good job on doing the implementation! I gave it two people to proofread and probably one just didn't do it (he said it's good), the other sent me a revised version, which did contain some style suggestions. It's not like I didn't try something. I'll try Grammerly. Haven't used it in ages. The implementation has some workarounds that I'd hope won't make it into the compiler. But as Walter pointed out in the Monthly Meeting, it's not obvious the grammar changes won't lead to weird parsings. Therefore, I hope the implementation can give people like you, Paul Backus, and Timon Gehr the opportunity to find holes or, hopefully, find none, which might be enough for Walter to dispel his concerns. |
September 22 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Quirin Schroll | On 22/09/2024 4:01 AM, Quirin Schroll wrote: > On Saturday, 21 September 2024 at 13:29:05 UTC, Richard (Rikki) Andrew Cattermole wrote: >> I recommend that you put it through Grammarly prior to Mike getting it, it'll lessen his workload. >> >> I.e. ``excpetion`` >> >> Otherwise it is looking pretty good, and good job on doing the implementation! > > I gave it two people to proofread and probably one just didn't do it (he said it's good), the other sent me a revised version, which did contain some style suggestions. It's not like I didn't try something. Yeah you did good, its just that tools are guaranteed to catch stuff like this :) > The implementation has some workarounds that I'd hope won't make it into the compiler. But as Walter pointed out in the Monthly Meeting, it's not obvious the grammar changes won't lead to weird parsings. Therefore, I hope the implementation can give people like you, Paul Backus, and Timon Gehr the opportunity to find holes or, hopefully, find none, which might be enough for Walter to dispel his concerns. Grammar stuff like this isn't where I shine, as long as it passes buildkite I'm happy. The text shows you've done your research and put in the effort. Ideally we'd throw a fuzzer at the parser to verify that it works as expected. https://llvm.org/docs/LibFuzzer.html https://johanengelen.github.io/ldc/2018/01/14/Fuzzing-with-LDC.html |
September 22 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Quirin Schroll | On Saturday, 21 September 2024 at 01:01:22 UTC, Quirin Schroll wrote: >The obligatory permalink and latest draft Not sure what was wrong with the other two drafts, but this one seems equally great. This feature would represent a massive improvement to string mixin code generation, and general language cohesion. Much like how you’re always allowed to use trailing commas in comma-separated lists. |
September 22 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Quirin Schroll | On Saturday, 21 September 2024 at 01:01:22 UTC, Quirin Schroll wrote: >The obligatory permalink and latest draft The grammar changes look good. I found some new ambiguities, but the implementation seems to always prefer the old meaning, so it should be no problem. Attributes with optional parens
The attributes The implementation seems to always try to parse the parens as arguments Maybe this could be confusing for the user, when a declaration uses a Scope guards
The first statement is a scope guard with the current grammar. With the The next line could also be a variable declaration, but it is still The last statement is parsed as a variable declaration, because scope Function literals
Function literals have an optional return type and optional parameters. The second function literal has both a return type and parameters, but Anonymous classes
The parens could be constructor arguments or a basic type in |
September 23 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tim | On Sunday, 22 September 2024 at 10:58:55 UTC, Tim wrote: >On Saturday, 21 September 2024 at 01:01:22 UTC, Quirin Schroll wrote: >The obligatory permalink and latest draft The grammar changes look good. I found some new ambiguities, but the implementation seems to always prefer the old meaning, so it should be no problem. In general, ambiguities are resolved considering Maximum Munch: If the next token can be parsed as part of the entity that the grammar suggests, it will be; only if it can’t, the entity is closed or it’s an error. >Attributes with optional parens
Those all fall under Maximum Munch: A parenthesis following any of these attributes constitutes their optional arguments. Attributes with optional arguments are greedy. I wasn’t even aware of The biggest one is The attributes The implementation seems to always try to parse the parens as arguments Yes, and it follows MM, which is generally something programmers can rely on. What can be done about those? For one:
Always works at declaration scope, but for statement scope, that’s not possible. Here, I thought one could use an empty UDA list Maybe this could be confusing for the user, when a declaration uses a type in parens and later an attribute is added. There’s unfortunately little that can be done about it. A better implementation can possibly backtrack and re-interpret what used to be an attribute’s argument as a basic type, but to be honest, that is a lot of work. >Scope guards
The big issue with these is, basically, that IMO this must work:
And it doesn’t. >The first statement is a scope guard with the current grammar. With the IIRC, I ran into this and implemented a look-ahead to handle scope guards correctly. The Scope guards utilize magic identifiers, and unlike The next line could also be a variable declaration, but it is still I just fixed that because it was fairly easy to do so. My implementation now looks ahead to see if it’s The last statement is parsed as a variable declaration, because scope This is interesting. It’s unlikely that something like that is going to be a real-world problem, though, as it requires two unlikely things: Someone naming a type My fix from above doesn’t change that, but again, it’s really unlikely to be in code anyways. >Function literals
Function literals have an optional return type and optional parameters. Yes, for backwards compatibility, it must be done that way. However, this is a MM violation and must be mentioned in the DIP. >The second function literal has both a return type and parameters, but The second one should be allowed; otherwise some things aren’t expressible. This should work because there’s no valid reason why it can’t:
However, this currently works and must keep behavior:
The implementation will do a look-ahead to figure out if it’s seeing It might be noteworthy that this is not a MM violation. There is no other way to parse Anonymous classes
The parens could be constructor arguments or a basic type in I going to look into this. Probably this is low-priority because a base class or interface name following I’ll commit my stuff probably tomorrow. I can’t do it now, unfortunately. |
September 24 Re: Third and Hopefully Last Draft: Primary Type Syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Quirin Schroll | On Monday, 23 September 2024 at 19:03:47 UTC, Quirin Schroll wrote: >I’ll commit my stuff probably tomorrow. I can’t do it now, unfortunately. Done. And I updated the DIP draft to include the new Maximum Munch exceptions. I did everything as suggested in my post, except for the anonymous class stuff. There, I was mistaken. The constructor arguments go first, then the base class / interfaces follow:
This means there is no real issue. If someone writes Please review the latest draft here. |