Open jcward opened 6 years ago
One more small aside : I ran into this same problem with promhx, but didn't have a great solution there either. I believe @back2dos handled this in tink by passing a dummy value.
well, modern languages use "functional" approach of having an universal Unit
value :)
A rose by any other name would smell as sweet.
I bet we could solve this with abstracts.™
While I agree this would be a nice goal, this is quite hard to deal with it tbh, because in a lot of cases (hxcpp for instance, but not only), there is a clear runtime difference between an argument of type T and 0 arguments, so when you start dealing with generics it becomes a lot harder.
On Fri, Dec 22, 2017 at 9:26 AM, Alexander Kuzmenko < notifications@github.com> wrote:
Maybe this can be handled in the compiler such as generic fields/properties which becomes typed as Void could not be accessed?
class Some
{ var value:T; function new() {} static function main() { var some = new Some
(); trace(some.value); //Error: Void field could not be accessed. } } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HaxeFoundation/haxe/issues/6793#issuecomment-353548187, or mute the thread https://github.com/notifications/unsubscribe-auth/AA-bwFNKzBUVM7d6ZtMdOd9ixl2fPzpDks5tC2fLgaJpZM4RKJYz .
We're talking about nicer handling of JS APIs.
This is how I deal with it: https://github.com/haxe-react/haxe-react-native/blob/master/src/Nothing.hx
Myabe we should use @kevinresol's until a proper solution is implemented? Maybe add Nothing
to haxe.Constraints
Separated this out of the conversation in #6790:
As long as we're thinking about js.Promise, it'd be nice if you could have a
Promise<Void>
(or just Promise), where resolve() and then(callback) expect no arguments. I know it's features like this that balloon the complexity, but I'm just saying -- it'd be nice. Otherwise I'm forced to write ugly crufty code like:Cludgy Dynamic, useless null, and empty ignore -- all terrible conventions.
Maybe it'd be possible with abstract EmptyPromise (Promise)?
Maybe @elsassph / @kevinresol have some thought?
@jdonaldson commented: