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

add haxe.NoData #9540

Closed
wants to merge 1 commit into from
Closed

add haxe.NoData #9540

wants to merge 1 commit into from

Conversation

nadako
Copy link
Member

@nadako nadako commented Jun 5, 2020

This is an unit type extracted from #9111, serving the same purpose as e.g. tink.core.Noise: to be a dummy value in value-places created by type parameters (e.g. Future<NoData>, Signal<NoData> and such).

Sample usage:

var signal = new Signal<NoData>();
signal.dispatch(NoData);

It's implemented as a single-variant enum abstract over Dynamic and is always just a null at run-time which is probably the most lightweight implementation.

I still think that normal Void could work the same way, but looks like that's not going to happen, so let's at least add this one, because it is needed very often and currently everyone has to implement their own thing.

Also I'm not sure if it should or should not be in StdTypes.

@nadako
Copy link
Member Author

nadako commented Jun 5, 2020

I still think that normal Void could work the same way

BTW, one concern that was raised when discussing this was the Void->Void vs (Void)->Void situation. I recendly found out that TypeScript is dealing with this by allowing skipping of void arguments, e.g. the following compiles:

class Signal<T> {
    dispatch(arg:T) {}
}

var signal = new Signal<void>();
signal.dispatch(); // no argument required

I personally don't like it to much though, because it makes arity unclear and I think signal.dispatch(void) is good enough.

@nadako
Copy link
Member Author

nadako commented Jun 5, 2020

Hmm, maybe I'll draft a haxe-evolution proposal about Void unit type...

@nadako
Copy link
Member Author

nadako commented Jun 6, 2020

Hmm, maybe I'll draft a haxe-evolution proposal about Void unit type...

OK, here we go: HaxeFoundation/haxe-evolution#76

@RealyUniqueName RealyUniqueName added this to the Design milestone Jun 10, 2020
@nadako
Copy link
Member Author

nadako commented Jul 2, 2020

I'll close this since we kind of agreed that we could re-use Void for this.

@nadako nadako closed this Jul 2, 2020
@nadako nadako deleted the nodata branch July 2, 2020 18:05
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.

2 participants