Amber icon indicating copy to clipboard operation
Amber copied to clipboard

Add function support to nameof keyword

Open Thesola10 opened this issue 10 months ago • 7 comments

Fixes #673.

Proof-of-concept, feedback is welcome!

Currently blocked by #770

Thesola10 avatar Feb 09 '25 09:02 Thesola10

From a review

the v0 shouldn't be hardcoded, as there may be undefined number of variations of the same function. not sure how you should select a variation in this situation, though

... I guess we forbid nameof on overloads. nameof implies breaking out of the Amber type system so there's no way to clearly select a variant anyway.

The alternative is compiling variants in a "turntable" function which would be returned by nameof, and handle type-checking the number and type of arguments at runtime. The turntable would only be compiled for functions nameof was called on.

Or a special syntax to denote the expected argument set, like nameof my_fun(Text, [Number]) in these situations.

Thesola10 avatar Feb 10 '25 09:02 Thesola10

I've also taken the liberty of changing the merge base from main to staging. I don't think this will cause any problems.

hdwalters avatar Feb 19 '25 21:02 hdwalters

Ah found an issue: this nameof doesn't mark the function as used, so if it's the only instance the function just doesn't get compiled.

Thesola10 avatar Feb 24 '25 09:02 Thesola10

I'm still not entirely happy with the hard-coded "v0" in your code change. However, I suggest that we defer further review on this PR until @Ph0enixKM's PR is merged, because AIUI it touches Bash variable name generation, and will consequently have an impact on this PR.

hdwalters avatar Mar 02 '25 14:03 hdwalters

@Thesola10 can you update with the feedback and the latest changes?

Mte90 avatar Apr 10 '25 09:04 Mte90

@Ph0enixKM to you think that this PR can be updated and moved on?

Mte90 avatar Oct 01 '25 09:10 Mte90

This PR is blocked by #770

Ph0enixKM avatar Oct 02 '25 13:10 Ph0enixKM