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

Default type parameters #10518

Merged
merged 13 commits into from
Jan 4, 2022
Merged

Default type parameters #10518

merged 13 commits into from
Jan 4, 2022

Conversation

Simn
Copy link
Member

@Simn Simn commented Dec 2, 2021

Also pretty wippy, but let's have a PR!

@skial skial mentioned this pull request Dec 2, 2021
1 task
@kLabz
Copy link
Contributor

kLabz commented Dec 2, 2021

Good thing github has nice options!
image

@AlexHaxe
Copy link
Contributor

please include an update for haxe.macro.Printer (needed by haxeparser tests and probably others)

@Simn
Copy link
Member Author

Simn commented Jan 1, 2022

I have disallowed usage on anything other than types and also adjusted haxe.macro.Printer. I think we're just about ready to merge this now!

@kLabz
Copy link
Contributor

kLabz commented Jan 1, 2022

🎉

Is that a hard restriction or mostly to be done with the important part (types) and possibly implement the rest later?

@Simn
Copy link
Member Author

Simn commented Jan 1, 2022

Well, the main issue is still that there's no syntax to define the type parameters explicitly, and without that this feature makes no sense.

@Simn Simn merged commit 4d07ebb into development Jan 4, 2022
@Simn Simn deleted the default_type_parameters branch January 4, 2022 08:34
@Aurel300
Copy link
Member

Should there be a check in the compiler that prevents type parameters without defaults to appear after type parameters with defaults? It makes sense syntactically, it is just really useless because:

class Example<T = Int, U = Int, V> { ... }

I cannot use the Example type unless I provide the third type parameter, which I can only do if I provide the first two type parameters as well.

@Aurel300
Copy link
Member

And a separate question: why can the default not be a previous type parameter, as in:

class Example<T = Int, U = T> { ... }

@kLabz
Copy link
Contributor

kLabz commented Apr 15, 2023

I specifically asked for typedef A = Example<_, _, String> back then and Simon seemed to agree but it seems like it wasn't implemented https://try.haxe.org/#DB2ECB50

I suppose the other question could be made to work too

@kLabz
Copy link
Contributor

kLabz commented Apr 15, 2023

seems like that would make sense and be consistent, so we probably won't do it.

Ah yeah that may not exactly count as agreeing 😅

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.

None yet

5 participants