-
Notifications
You must be signed in to change notification settings - Fork 131
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
There is no way to distinguish a non-existing symbol from one bound to VMnull #735
Comments
Apparently, the preferable fix would be to add |
Where does this problem pop up? VMNull is an internal thing that is not
available to normal Raku users. So in which situations do we bind a VMNull to
a dynamic variable and still treat it as declared?
|
Also, So to me, having something be So this feels like a non-problem to me: |
For any collection type that is supposed to be able to have elements of any type at all, it seems a very poor design decision to have a special value to indicate no value, which is logically a contradiction in terms. It sounds like Raku is behaving here analagously to using the Perl code |
@duncand Raku has @duncand This is about the very low level implementation in Rakudo. Nothing to do with design. I suggest you familiarize yourself with Raku features before seemingly providing judgment. |
Even NQP doesn't default undefined variables to |
I have tripped over this problem while working on rakudo/rakudo#4495. One of the problems with pseudos which always annoyed me is that But for chained pseudos like There is a workaround which would use manual iteration over contexts to find the requested symbol for So, generally speaking, I agree with @duncand in the point that using a special value to indicate absence of something doesn't look good to me in this particular case. |
Isn't the DIHWIDT caused by the fact that |
|
Anyway, of course I can drop the idea of testing for roundtrip behavior of pseudos because it would be unreliable. But it would remain a mystery to me why is it a problem to add a set of ops which are basically identical to the existing ones except for the different return value and its meaning? |
I think the idea of testing is good. If |
First of all, you can't do for DYNAMIC::.keys -> $sym {
ok DYNAMIC::{$sym}:exists, "$sym exists"; # not ok on $*DISPATCHER
} And, apparently, |
@lizmat I'm talking about implementation design. While I'm not an expert or implementer in Raku I have been involved with it to a degree since 2005 and feel I understand enough to give some feedback. In this case I'm going on @vrurg own comments and the leading discussion as a basis for how things seem to work and I'm not second-guessing whether what they said is true. I'm taking However, I apologize that my exact choice of words |
@duncand no worries. It felt that you were talking about HLL issue of being able if something exists or not. For which Raku does have a solution that doesn't depend on a special value (well, at least visible from Raku / NQP. I'm pretty sure Perl hashes actually use a special value to indicate a key has been removed internally, to avoid churn). @vrurg: maybe |
@lizmat I'm considering this. Not only |
No, it's not an option. Things are totally different about lexicals. These are known at compile time. Therefore the following is working: use nqp;
my $nullish := nqp::null();
sub foo {
say $nullish; # (Mu)
}
foo But for pseudos it is crucial to know their symbols at run time. Therefore, replacing The argument of BTW, there is catch in the situation. Because Eventually, I'm currently have only the following options if the decision not to add
|
The argument of `nqp::null` not being valid in Raku land is not compelling
to me because it is neither formally nor technically prohibited. Therefore,
binding to `VMnull` is possible, though perhaps not pretty. In some cases,
it might be useful if done with care.
But you can get a VMNull only through nqp::null. And nqp is an implementation
detail and its use has been strongly discouraged since the very beginning.
There are lots of ways you can break Rakudo and get completely bogus results
by using nqp. Why should we treat this one case specially?
|
I'm not talking about breaking, but rather about having a faster way for correct symbol introspection. It is currently possible to collect all available symbols by iterating over lexpads manually. But when it comes to finding out if a symbol exists
Perhaps to have it done the right way? We all know that returning a value to signal about absence of an entry is no good if entries can carry that value. The reason I'm do not agree is because "strongly discouraged" doesn't mean "disallowed". I mean, as soon as Anyway, I'm giving up and reconsidering my approach. However, I'm still puzzled as to why are you so reluctant to adding these ops? What's the reasoning behind this opposition? Because so far it all sounds just like "it is good as it is" which unconvincing. Would it affect optimizations? Would it bring extra complexity? Would it... what? My curiosity craves for food. :) |
The following code throws in Raku:
because with
nqp::getlexdyn
op there is no way to distinguish wetherVMnull
is returned due to a missing symbol, or the symbol is bound toVMnull
. The problem is common across allnqp::getlex*
family ops. It means that in the current situation one would need to manually reproduce the internal behavior of a particularnqp::getlex*
op to find out what exactly caused the negative outcome.The text was updated successfully, but these errors were encountered: