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
Lock.protect({}) fails, but with surprising message #1644
Comments
Apparently the LEAVE phaser is executed even though the method itself never got passed parameter binding |
|
FWIW, I hate this. I keep getting into this trap. I guess the only way to have an empty block is to do Maybe we should tweak the language instead? Not necessarily now, but 6.d or 6.e… |
That's as-designed. The binding is attempted inside the sub's block so LEAVE gets run when we leave the block after binding failure (this is documented in traps too)
Also, Ruby, Python, and JS/JSON (objects are very similar to hashes).
👎 just based on the sheer amount of Also |
|
@zoffixznet I agree with your post, though there might be an argument to be made that in ruby/python/js it’s not actually an issue, since the lambda syntax is |
|
The argument might've been made when the language was being designed. Right now, making such a significant change would be just pissing off—and losing—users. |
|
Perhaps, once object hashes have the same performance as Str hashes, we can repurpose the :{} syntax to mean “hash”
… On 26 Mar 2018, at 17:01, Zoffix Znet ***@***.***> wrote:
-> {} is a lambda in Perl 6 as well. As is {;}. It's not the same syntax for lambdas and hashes and the rules are well-defined.
The argument might've been made when the language was being designed. Right now, making such a significant change would be just pissing off—and losing—users.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
We can do better than this by setting a flag saying we did indeed acquire the lock, and only releasing it if we actually did. It's actually a potentially more dangerous bug when one considers lock recursion, since then it could fail silently in the immediate, and then at a distance later. I'll reopen this issue now, and fix it up.
Yes, and this is one place where there's no really right answer, given that one can do things like: And then it'd be a trap in the other direction.
It was. In fact, it's a good default assumption that - having had 15 years of design time - nearly all aspects of the Perl 6 design received no small amount of discussion before settling on the current state. Given how many ways in which Perl 6 differs from Perl 5, it's also a reasonable default assumption that those designed choices made the same way are intentionally that way, also after considering the options. |
FWIW, after db7361a the error for OP's version of the code is |
Yeah, that's a decent way to do it too; the text linking the commit is pretty tiny and I missed it. I'm doing a similar fix for |
|
Fixed for |
Sorry but this thread makes no sense to me.
I think there's little use in naysaying, and instead we can just let the interested parties to think and discuss what would be a better way to do something. If it's different from what we actually have in perl 6, it can then be discussed if something can be changed (and if it's worth changing at all). Anyway. I'm probably stealing this ticket and driving it full off topic, but another way of thinking about the
With this info I really don't know if it's worth changing (more like not). But… who knows? ;) |
|
Links:
|
|
Another one:
|
I had some code using Lock.protect():
Commenting out some code during development left me with an "empty block":
Which resulted in an error message like this:
I agree that this is an error, because what I intended to be an empty block is in fact a hash literal. However the error message is a little bit less than awesome. and surprising, given:
results in:
Not sure what could be special about Lock.protect...
The text was updated successfully, but these errors were encountered: