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

first draft implementation self.WHO to return package of a class #402

Closed
p6rt opened this issue Nov 10, 2008 · 5 comments
Closed

first draft implementation self.WHO to return package of a class #402

p6rt opened this issue Nov 10, 2008 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 10, 2008

Migrated from rt.perl.org#60446 (status was 'resolved')

Searchable as RT60446$

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @chrisdolan

The attached patch attempts to implement the WHO method from S12.
With this patch, I get the following output​:

  % ../../parrot perl6.pbc -e'class Foo​::Bar {}; say Foo​::Bar.new.WHO;'
  Bar

  % ../../parrot perl6.pbc -e'class Foo​::Bar {}; say
Foo​::Bar.new.WHO.WHAT;'
  Module

However, this implementation has the following flaws​:
  * the WHO package stringifies to the shortname, not the longname
specified in S12.
  * The following identity test fails​:
  % ../../parrot perl6.pbc -e'class Foo​::Bar {}; say
Foo​::Bar.new.WHO === Foo​::Bar'
  0

@p6rt
Copy link
Author

p6rt commented Nov 10, 2008

From @chrisdolan

who.patch
Index: languages/perl6/src/classes/Object.pir
===================================================================
--- languages/perl6/src/classes/Object.pir	(revision 32442)
+++ languages/perl6/src/classes/Object.pir	(working copy)
@@ -405,6 +405,20 @@
     .return self.'WHERE'()
 .end
 
+=item WHO
+
+Gets the object's package
+
+=cut
+
+.sub 'WHO' :method
+    .local pmc p6meta, class, ns
+    p6meta = get_hll_global ['Perl6Object'], '$!P6META'
+    class = p6meta.'get_parrotclass'(self)
+    ns = class.'get_namespace'()
+    .return (ns)
+.end
+
 =back
 
 =head2 Private methods

@p6rt
Copy link
Author

p6rt commented Dec 4, 2008

From @jnthn

When this patch is applied/WHO is implemented, we should also do an
update to the .perl method in ProtoObject to use the value of .WHO, not
.WHAT.

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

From @moritz

We have a .HOW method on all object these days, so I hope nobody
complains when I close this ticket.

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

@moritz - Status changed from 'new' to 'resolved'

@p6rt p6rt closed this as completed Mar 9, 2010
@p6rt p6rt added the patch 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