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

Should Promise.noise() just return the promise itself? #130

Closed
nadako opened this issue Jun 15, 2020 · 8 comments
Closed

Should Promise.noise() just return the promise itself? #130

nadako opened this issue Jun 15, 2020 · 8 comments

Comments

@nadako
Copy link
Contributor

nadako commented Jun 15, 2020

Given that Noise has from Dynamic so this is possible:

var s:Noise = "not null";

(and thus there's no guarantee that two Noise-typed values are equal)

Shouldn't Promise.noise just return this to save some allocations?

@nadako
Copy link
Contributor Author

nadako commented Jun 15, 2020

Also I need some clarification about the deprecation of Promise/Future.NULL, e.g. if I have:

var f:Future<String> = if (...) getActualFuture() else Future.NOISE;
f.handle(value -> /* should I check for `null` here? */);

To be honest I'd prefer something that is explicitly specified to resolve to a null, especially given that Noise can be anything because of from Dynamic...

@back2dos
Copy link
Member

back2dos commented Jun 16, 2020

The code should not compile with null safety, because Future<Noise> is merely Future<Null<String>>.

And yeah, the from Dynamic is new and should probably be given more thought. Probably @:from Dynamic return null would be better.

@nadako
Copy link
Contributor Author

nadako commented Jun 16, 2020

So does that mean that Noise is/should be specified to be null at run-time? ^^

@back2dos
Copy link
Member

Indeed. The whole point was to have only one value. I think :D

@nadako
Copy link
Contributor Author

nadako commented Jun 16, 2020

Hm, I wonder if it makes sense to have a cached instance of Outcome(Noise) too (for Promise.noise).

@back2dos
Copy link
Member

Why not ;)

@kevinresol
Copy link
Member

Need this HaxeFoundation/haxe-evolution#10 (comment) ?

@back2dos
Copy link
Member

Not necessarily, but it'd be a nice solution :)

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

No branches or pull requests

3 participants