HaxeFoundation / haxe-evolution

Repository for maintaining proposal for changes to the Haxe programming language
111 stars 58 forks source link

Local Variable Metadata #74

Closed Antriel closed 4 years ago

Antriel commented 4 years ago

Add new syntax for metadata on local variables: var @:meta foo:Bar;.

Rendered Version

Simn commented 4 years ago

I'm in favor of this, but at least two things still need clarification:

Antriel commented 4 years ago

First point added, not sure what exactly you mean by the second one. What are metadata function arguments? Do you mean an example comparing the currently available solution (moving the metadata up to method level) to how it could look like with the new syntax? I don't see how that offsets the "different from class fields" point.

Simn commented 4 years ago

I mean that function test(@:meta x) {} is already valid syntax and aligns nicely with this proposal.

Antriel commented 4 years ago

Added. I didn't even know about that one (or forgot, regardless, I didn't find it in the manual). :)

haxiomic commented 4 years ago

Maybe it would make sense for the alternative syntax to also work (@:meta var foo: Bar), because I think that's the one users will likely try first when they add meta to variables

Antriel commented 4 years ago

I agree. I like that solution more. As I outlined, maybe it could be implemented by duplicating the metadata of var declaration expression into the var itself. I am not sure how difficult, if even possible, it is. I'm also not sure what consequences it might have to existing code (I can't think of any though).

Simn commented 4 years ago

No, we won't change it like that. It's expression metadata and shouldn't become a special case for local variables. It also doesn't play well with comma syntax.

haxiomic commented 4 years ago

Ahh agreed, I misunderstood the proposal initially

Simn commented 4 years ago

We have decided to accept this proposal in our haxe-evolution meeting yesterday.

There's not much to say about this one. Progress will be tracked in the linked Haxe issue.