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

Draft and Discussion to figure out custom namecall self type definition #51

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

karl-police
Copy link

@karl-police karl-police commented Jul 31, 2024

The RFC: https://github.com/karl-police/rfcs/blob/patch-1/docs/user_defineable_self_namecall_type.md

It's basically just all about how self isn't controllable compared to Class.TestMethod(self: insert_type_here)

function Class:TestMethod()
        -- Default Compile Optimization thanksfully seems to skip this, which is good.
        -- Otherwise this alternative would have a optimization impact.
	self = self :: ClassObject
end

and how : takes away the first argument, but I am not sure if this would cause issues for the typesolver. It seems to work fine when using --!strict when doing self = self :: ClassObject

and when looking at the Bytecode

I don't see a instruction in the code where it is processing self = self which makes the current alternative within pure : functions possible, but annoying.

But if Bytecode Compilation ever gets changed by Luau where self = self would count as a MOVE instruction, then this would be bad.

@karl-police karl-police marked this pull request as draft July 31, 2024 17:14
@andyfriesen
Copy link
Collaborator

Some of this is going to get a lot better when we implement https://github.com/luau-lang/rfcs/blob/master/docs/shared-self-types.md

@andyfriesen andyfriesen self-assigned this Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants