Skip to content

Even less cheating in class.c #23544

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

Merged
merged 3 commits into from
Aug 12, 2025
Merged

Conversation

leonerd
Copy link
Contributor

@leonerd leonerd commented Aug 6, 2025

Building on top of ec78f9b, this sequence of commits further removes special-case code in class.c by getting the subsignature API to build the signature ops for generated accessor methods, rather than performing custom work itself.

Part of this change also involves simplifying the API for subsignature_append_positional() and subsignature_append_slurpy(), which also simplifies code in toke.c as a side benefit.

All of these changes are in support of better signature generation code that ultimately helps with the faster-signatures branch and named parameter support.

@leonerd leonerd force-pushed the even-less-cheating-in-class.c branch 2 times, most recently from c4b4d29 to 13afe17 Compare August 9, 2025 16:42
Copy link
Contributor

@tonycoz tonycoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the discussion on IRC, I can't think of a better subject for the first commit either 😄

This simplifies potential callsites from other locations, avoiding their
need to create the special weird OP_ARGELEM fragments. Additionally this
decouples the knowledge that these operations are run on OP_ARGELEM ops
in the first place, allowing for a future version that operates
differently.
Previously, the op fragments created here were woven into the signature
handling part of the final optree and had to contain a few extra fields
related to signature argument handling. Since `subsignature_finish()`
now creates the entire optree itself, the ops created by the tokenizer
are only used for their side-effect of containing the pad offset in
`op_targ`. As such, they no longer need to be specially sized OP_ARGELEM
and can be regular OP_PADANYs.
This removes a bunch of special-case logic from `class.c`, making it
behave much more similar to regular user-defined methods in the way it
creates the signature-handling part of its optree.
@leonerd leonerd force-pushed the even-less-cheating-in-class.c branch from 13afe17 to 0bcda08 Compare August 12, 2025 10:34
@leonerd leonerd merged commit 0b0c873 into Perl:blead Aug 12, 2025
33 checks passed
@leonerd leonerd deleted the even-less-cheating-in-class.c branch August 12, 2025 11:54
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.

3 participants