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

Are metaclass methods tested? #4497

Open
JJ opened this issue Aug 21, 2021 · 4 comments · May be fixed by Raku/roast#756
Open

Are metaclass methods tested? #4497

JJ opened this issue Aug 21, 2021 · 4 comments · May be fixed by Raku/roast#756
Labels
tests needed Issue is generally resolved but tests were not written yet

Comments

@JJ
Copy link
Collaborator

JJ commented Aug 21, 2021

The Problem

Metaclass methods (method ^foo) were introduced in 2015.03. They don't seem to have been tested either in Rakudo or in roast.

Expected Behavior

That's the problem, not clear what's the expected behavior. "Metaclass" methods seem pretty descriptive, but it's not clear if this adds a method to the actual metaclass, or simply adds a method that can be accessed via the HOW. I imagine it's the latter, but still, a test would really help create a use case for Raku/doc#2856

@jnthn
Copy link
Member

jnthn commented Aug 23, 2021

They should be tested. They work by creating an anonymous role containing such methods, and mixing it into the metaclass instance for the class.

@vrurg
Copy link
Member

vrurg commented Aug 24, 2021

I have a tab with Raku/roast#553 opened for two years already. But there is always something with higher priority...

@jonathanstowe
Copy link
Contributor

a tab with Raku/roast#553 opened for two years

I'm glad someone else uses their browser tabs as a TODO list 😃

@vrurg
Copy link
Member

vrurg commented Sep 2, 2021

I'm trying to figure out what'd be necessary to spec about metamethods? Aside of the evident:

class Foo { method ^foo(\obj) { ... } }
Foo.^foo;

We could spec for:

  • obj to be the invocant (Foo in the above case, Foo.new with Foo.new.^foo, etc.)
  • self to be a Metamodel::ClassHOW. At least this part of the metamodel is specced in Roast.
  • no parameter needed if invoked as Foo.HOW.foo

And that's basically it. I wouldn't even spec the implementation detail of a role being mixed into HOW.

One behavior is certainly the candidate for Roast:

class C1 { method foo(\obj) { say "meta" } }
class C2 is C1 { }
C2.^foo; # meta

Not sure if many people know about this.

vrurg added a commit to vrurg/roast that referenced this issue Sep 3, 2021
We never tested for

    class Foo {
        method ^foo($) {...}
    }

Resolves rakudo/rakudo#4497 and Raku#553
@vrurg vrurg linked a pull request Sep 3, 2021 that will close this issue
@lizmat lizmat added the tests needed Issue is generally resolved but tests were not written yet label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests needed Issue is generally resolved but tests were not written yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants