-
Notifications
You must be signed in to change notification settings - Fork 55
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
Generalize error constructors to mappings and lists #2
Comments
Blocked by #27 |
This depends on issue #67, which was previously included in this. |
I have separated the error-specific part of this into #223, so this issue is just about generalizing that to mappings and lists. |
I remain concerned that this syntax is going to be utterly confusing to Mort. Making new XML elements with that syntax will further make matters worse. I would like to use
If the type name is a verb then it becomes really messy to read and instantly see what that code is doing. You can argue that "well data types should not be named as verbs" but majority of the world's programmers (esp Morts) are going to be non-native English speakers and correct grammar is not a major requirement to be a programmer :-). |
Your example is confusing not merely because of the use of a verb rather than a noun, but because you are not using a naming convention to distinguish type names from other names. Given that type names share a symbol space with other names, it is crucial for clarity in Ballerina that type names using a naming convention to distinguish them, such as an initial capital letter or a _t suffix (like in C). (With hindsight, it might have been better if we had adopted this convention for our built-in non-simple types.) So your example would more realistically be
I disagree with the idea of using At this point, I think our choices are to go ahead as designed for R2, or not. It's a feature we can live without for now. But in either case, I do think we need to do #223, otherwise our error handling will be very awkward. |
Another difficulty is that it would break the clear story that we currently on when |
IMO the duplication of I would prefer to not do this for R2/R3 and defer it to give it more consideration. I agree we need to go ahead with this for 223, but given error values are in their own value space I don't see that as necessarily saying the only way to address this issue is with the same syntax. |
There is an interesting question about what the semantics of this in a match-pattern. Suppose R is a record type and consider match x {
R() => { var y = x; }
} When does the match succeed? Is it when x looks like R (ie the current shape of x is in R) or is it when x belongs to R (ie the inherent type of x is a subtype of R)? I believe the right answer is the former, since match is about the current shape of things, not the type (the if clause checks type), and this is consistent with not narrowing the type of x in the match. Note that for the case of error in #223 this does not arise, since errors are immutable meaning looks like and belongs to are the same for error. |
Relates to #152. |
Given the solution to #497, we are not doing this. |
Problem:
Error constructors use a function-like syntax in what seems to be a rather ad-hoc way
Solution:
Generalize error constructor (with changes from #2) into a functional constructor, which would be useable for both construction and pattern matching.
The named-type-reference specifies the contextually expected type. The interpretation of arg-list depends on the basic type referred to:
Note that
new
is restricted to behavioural types (matching the current impl).The text was updated successfully, but these errors were encountered: