Skip to content
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

cannot override isa() if PIR uses isa opcode #440

Closed
p6rt opened this issue Dec 1, 2008 · 7 comments
Closed

cannot override isa() if PIR uses isa opcode #440

p6rt opened this issue Dec 1, 2008 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 1, 2008

Migrated from rt.perl.org#60946 (status was 'rejected')

Searchable as RT60946$

@p6rt
Copy link
Author

p6rt commented Dec 1, 2008

From @chrisdolan

I'm trying to make mock objects in Rakudo, but the 'isa' opcode in
PIR seems to ignore my overridden isa() method. The attached code
sample demonstrates the problem by​:

1) creating a mock class that overrides isa()
2) calling .WHAT to ensure I built the right class
3) calling .isa to show that the mock works
4) invokes the isa opcode in PIR to test that the mock acts like the
mocked class

Expected result​: step 4 returns true, just like step 3
Actual result​: step 4 returns false

The last step shows that PIR is not fooled by the mock class. I
worry that this scenario will cause UNIVERSAL​::isa problems all over
again. I expect that the same problem will arise from the 'can' opcode.

@p6rt
Copy link
Author

p6rt commented Dec 1, 2008

From @chrisdolan

isa.pl

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

From @ronaldxs

From IRC discussion on 4/29

13​:54 pmichaud at the moment I think I'm going to declare RT #​60946
(sic.) "not a bug" and let it slide for now. We don't currently make
any guarantees that Rakudo objects play nicely with Parrot 'isa' opcodes.
13​:54 PhatEddy The ticket seems to ask whether parrot class isa should
work like Perl 6 class isa. It might be sort of nice if it did but not
necessary ...
13​:55 pmichaud I agree it would be nice if it does. Eventually it
hopefully will. But Parrot vtables don't map cleanly to Perl 6's methods.
13​:55 We currently have to do lots of vtable-specific workarounds.

Test tacked on in case someone wants to do further work on this some day.

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

From @ronaldxs

use v6;

use Test;
plan 1;

class Mock​::PGE​::Match {
  method isa($x) { return $x === PGE​::Match || self.HOW.isa(self, $x); }
}

sub get_pir_isa_pge_match {
  Q​:PIR {
  get_hll_global $P0, ["Mock";"PGE"], "Match"
  $P1 = $P0."new"()
  $I0 = isa $P1, ["PGE";"Match"] # add "Mock" to fudge success ...
  .return ($I0)
  }
}

is get_pir_isa_pge_match(), Mock​::PGE​::Match.new.isa(PGE​::Match),
  'RT 60946 pir isa override';

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

From @pmichaud

On Sun Nov 30 21​:05​:13 2008, chris@​chrisdolan.net wrote​:

I'm trying to make mock objects in Rakudo, but the 'isa' opcode in
PIR seems to ignore my overridden isa() method.

...and that's likely to be the case for some time to come.

In general, Parrot's vtable functions don't map well onto
method calls, as would be the case if someone overrides 'isa',
'Str', 'true', etc. In the specific case of VTABLE_isa, overriding
it to respond instead to the Perl 6 '.isa' function means that many
of Rakudo's internals are left without a way to do a true "isa" test
(which it currently has to do in order to find out the true underlying
representation of some classes).

For now, the bottom line is that we're probably not going to worry too
much about making all method overrides in Perl 6 appear correctly to PIR
opcodes; especially in those cases where we need the PIR opcode's
functionality to mean something else for internals.

So, closing ticket for now -- we can revisit the issue later (as part of
handling vtable functions in general).

Pm

@p6rt
Copy link
Author

p6rt commented Apr 29, 2009

@pmichaud - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Apr 29, 2009
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant