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
Semantics of coercion type on an "rw" parameter #21
Comments
|
Initial proposal: I see two main options. We could make it a compile-time error, so folks can't run into it accidentally. This avoids any further gotchas in this area. However, this could break working code that is successful because all the cases that exercise it pass a matching type. Alternatively, we could define the use of a coercion type together with Would result in Would require one, and would potentially as part of signature processing mutate |
|
In this situation, I suggest that in this situation: The coercion is fine, since there is no type applied to $x. However in the more restrictive situation: The coercion is incorrect and should generate a run-time exception. Thoughts? |
I don't mind that behavior at all. Just a quick type check on the assignment. I think that'd be a pretty nice if eventually we could specify coercion on assignment such that: Could recoerce back to Int upon completion, if possible, and generate a run-time exception otherwise, but doing a coercing assignment would be a very different topic indeed, so I digress. As to the concerns that Jonathan had, from a user perspective, I'd expect to work more or less like this: In other words, the coerced value would be temporarily stored, and only properly assigned to the rw container upon a successful signature completion. |
This is what I'd expect, yes.
Signature binding is defined as processing the parameters in order. The point of the |
|
Is there consensus that it would be good to have a general principle along the following lines?
|
|
@raiph I do like the idea to introduce compiler errors when a construct is clearly problematic and serves no use. How could such a policy introduced? Is this a topic for the RSC? |
|
I feel like this problem is too abstract to have a good discussion about it.
Best answer I could give is probably "sounds sensible, but the best course of
action depends much more on the concrete semantic".
|
|
As far as I can remember, making something a compile time error when semantics are still unclear, has been the policy. That's why we have a |
Currently, if writing:
Then we can call it successfully like this:
However, if the coercion is applied, such as in this case:
Then it binds the result of the coercion to
$ninfoo, resulting in an error since++is being done on an immutable value. This is almost certainly the result of not having considered how this interaction should work.The text was updated successfully, but these errors were encountered: