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

Give nqp named anon methods #772

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Give nqp named anon methods #772

wants to merge 1 commit into from

Conversation

Kaiepi
Copy link
Contributor

@Kaiepi Kaiepi commented May 17, 2022

Allows for the following pattern:

nqp::getstaticcode(
    anon method introspective() {
        nqp::die('nice callstack!')
    });

Which would be very useful in Rakudo's bootstrapping, for instance. Many of Rakudo's core methods lack names on their code objects, which tends to be rather confusing for newcomers introspecting methods.

Unsure of how to add a test for this.

@Kaiepi Kaiepi force-pushed the named-anon branch 2 times, most recently from b080820 to d06b751 Compare May 17, 2022 06:23
Allows for the following pattern:

```raku
nqp::getstaticcode(
    anon method introspective() {
        nqp::die('nice callstack!')
    });
```

Which would be *very* useful in Rakudo's bootstrapping, for instance.
Many of Rakudo's core methods lack names on their code objects, which
tends to be rather confusing for newcomers introspecting methods.
@Kaiepi
Copy link
Contributor Author

Kaiepi commented May 17, 2022

This should demonstrate that this behaves:

class WithNamedAnon {
    method named_anon() {
        nqp::getstaticcode(anon method named_anon() { })
    }
}

my &named_anon := WithNamedAnon.named_anon();
say(nqp::getcodename(&named_anon) eq 'named_anon');
say(!(named_anon(WithNamedAnon) =:= &named_anon));

@lizmat lizmat requested a review from jnthn May 17, 2022 08:03
@coke coke changed the base branch from master to main April 19, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant