On Saturday, 13 May 2023 at 11:13:59 UTC, Nick Treleaven wrote:
>It seems we could add this form to Type for consistency with function literals:
function RefOrAutoRefopt Type ParameterWithAttributes
May 17, 2023 Re: D needs a type expression syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Treleaven | On Saturday, 13 May 2023 at 11:13:59 UTC, Nick Treleaven wrote: >It seems we could add this form to Type for consistency with function literals:
|
May 17, 2023 Re: D needs a type expression syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Treleaven | Note: The On Saturday, 13 May 2023 at 11:13:59 UTC, Nick Treleaven wrote: >Just noticed we have this form for function literals:
https://dlang.org/spec/expression.html#function_literals But for function types we have just:
https://dlang.org/spec/type.html (inlining the TypeSuffix form) It seems we could add this form to Type for consistency with function literals:
Technically, that would work. I disagree with “for consistency,” however. The current consistency is that the order of keyword and type make it a type or a literal. Optional elements aside, a function literal looks like this:
and its type is:
You see, if the keyword ( The problem D has is that while
is valid syntax for the literal, the corresponding
is not a valid type – except in an If I understand you correctly, you’d also allow
as a type, that is, when the function doesn’t return by reference. (It would be really inconsistent if that wasn’t allowed.) The distinguishing factor then is what follows this whole long sequence of tokes. If it’s a brace, So this works: But for the type of a function returning by value, you’d then have two syntaxes, right?
I don’t think this would be a great thing. >[…] Depends on how you measure impact or what you consider small:
Considering that The smaller-impact solution is to make If the syntax like I really don’t like this because the |
May 17, 2023 Re: D needs a type expression syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Treleaven | On Wednesday, 17 May 2023 at 12:08:41 UTC, Nick Treleaven wrote: >On Saturday, 13 May 2023 at 11:13:59 UTC, Nick Treleaven wrote: >It seems we could add this form to Type for consistency with function literals:
I implemented my original approach, but some checks don’t work. You might want to look into it. This is the first time I’m working on the compiler. It’s probably some stupid error that I just cannot spot. I’d really appreciate some help with it. |