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

PPC0033: method-like calls to lexical subs #68

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

haarg
Copy link
Contributor

@haarg haarg commented Jan 22, 2025

Add a syntax $object->&method(@args) that calls method as a sub, to allow a nicer syntax for private methods.

Add a syntax $object->&method(@Args) that calls method as a sub, to
allow a nicer syntax for private methods.
@esabol
Copy link

esabol commented Jan 22, 2025

I think the "Future Scope" section should be part of the current scope of this PPC. If it were, I'd fully support it. class is here now, and putting off any class-related implementation of this PPC to some nebulous future only makes the transition to using class less attractive and take longer.

@haarg
Copy link
Contributor Author

haarg commented Jan 22, 2025

I will clarify that this should work for public methods in the class syntax, but I had put that in the future scope section because my method is not yet supported. This PPC would be a way to make lexical methods in the class syntax viable, but support for lexical methods is a separate issue from the call syntax.

@leonerd
Copy link
Contributor

leonerd commented Jan 23, 2025

I've had a go at implementing the my method syntax in Perl/perl5#22940 as it was an oversight not to have done it anyway. That said, we might want to wait until implementing this PPC as well to get them both in at once, to avoid an intermediate situation whereby my method exists but ->& does not, leading to having to suggest the "just call it like a sub" workaround.

haarg added 5 commits January 28, 2025 03:38
Methods under the "class" syntax would also be callable using this
syntax. Lexical methods currently don't exist, but they would be
callable with this syntax if they were added.
@leonerd
Copy link
Contributor

leonerd commented Jan 30, 2025

I'm definitely in favour of this. In fact if it were merged soon I'd like to get an implementation of it added in with my my method PR above. It makes sense to add them both together; as either without the other is rather pointless. So the PR is largely waiting on this idea.

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.

4 participants