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
Fail with typed errors if nqp::open dies in IO::Handle.open. #894
base: main
Are you sure you want to change the base?
Conversation
Also removes an expensive check necessary to avoid opening directories: This is now handled at the VM level, which still needs to happen on the JVM (cf Raku/nqp#310).
|
It's quite possible to throw a typed exception from the VM level as I've recently learned. It's just a little more involved. Look for P6EX in the source. OTOH the additional checks are done only in an error case anyway. And how much performance are you gonna need there? |
Wouldn't that introduce a dependency on the specific HLL?
It's not about performance, but having to duplicate the checks independently on the p6-side. Such a repetition just introduces another chance to get it wrong, which in fact I already managed to do (cf 191f68e). It's also a bit iffy in so far as in principle, the file in question could have been modified between the failure of the call to |
|
Is this PR still good or does its approach need to be changed entirely? Lack of untyped exceptions from open turned up here, today https://stackoverflow.com/questions/48865412/how-should-i-handle-perl-6-argfiles-that-cant-be-read-by-lines |
|
Conflicts aside, it should still be good(-ish). The |
Oh, whoops. Yeah, I've just actually looked at the code and not too happy with such decisions what what exceptions to throw. There's definitely a way to throw typed VM exceptions... I'll look into that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is introducing a new class, as well as proposing a new (kinda) feature. So there're a few things that need to be done
- Fix the conflicts
- Provide an use case for it
- Turn that use case into a test, and submit it to roast.
Then we can discuss if this is really needed, in the problem-solving repo if necessary. Thanks anyway for the PR.
|
I am unsure as to the status of this PR. Can someone enlighten? |
|
The #?if jvm can go. It would indeed be better if the VM threw the typed exception. The mechanism for this does not create a dependency on the HLL (it's already in use in several places after all without trouble). Doing those checks twice does indeed create a race condition where the cause of the error may change between the checks. Nevertheless, if no one volunteers to implement throwing typed exceptions at the VM level, then we'd still be better off with this merged. Race condition and all. |
What kind of mechanism do you mean here? |
|
There are several fields for handlers that generate typed exceptions in the
HLL config:
https://github.com/rakudo/rakudo/blob/master/src/Perl6/bootstrap.c/
BOOTSTRAP.nqp#L3902
Though I'd like to have an even easier way of throwing typed exceptions from
the VM level. If all it'd take is an entry here and an entry there, we
wouldn't use MVM_exception_throw_adhoc all the time and never have to parse
exception messages in Rakudo...
|
|
@niner I have implemented a replacement for
When used it looks much tidier and readable than rakudo/src/Perl6/Metamodel/CoercionHOW.nqp Line 205 in 12b49b8
X.
But use it from inside a VM would still be complicated by requiring named parameters for exception constructor. |
|
Is this PR still salvageable ? |
Also removes an expensive check necessary to avoid opening directories:
This is now handled at the VM level, which still needs to happen on the JVM (cf Raku/nqp#310).
It could be made even nicer if there was a way to communicate error types to the HLL, eg via error codes provided in addition to the error message. Currently, we're forced to (non-atomically) repeat checks that already have been performed at the VM level (or parse error messages).