djinni icon indicating copy to clipboard operation
djinni copied to clipboard

future<void>

Open li-feng-sc opened this issue 3 years ago • 5 comments

Currently future<> type requires a non-void type, because void is not a valid Djinni type. This means the IDL cannot represent a future with no value, but only a completion status.

li-feng-sc avatar Mar 16 '22 01:03 li-feng-sc

+1, this is quite awkward without

bkotsopoulossc avatar May 05 '22 00:05 bkotsopoulossc

  • The C++ Future can already support Future<void>
  • Java has java.lang.Void that can be used to box a void value.
  • What is ObjC's equivalent of java.lang.Void?
  • Javascript Promise also already supports Promise<void>.

li-feng-sc avatar May 20 '22 05:05 li-feng-sc

Seems like everything is easy except obj-c. I don't think they have a boxed version of void. Do you need a boxed type? Maybe NSValue or a void* or something? What are the constraints?

bkotsopoulossc avatar May 20 '22 16:05 bkotsopoulossc

Hi,

In obj-c you have type id: https://riptutorial.com/objective-c/example/16005/id

I don't know if it help.

The java.lang.Void can be integer? https://stackoverflow.com/questions/10839042/what-is-the-difference-between-java-lang-void-and-void

Thanks.

paulocoutinhox avatar May 26 '22 05:05 paulocoutinhox

For Objective-C, maybe NSNull?

nolanw avatar Sep 27 '22 20:09 nolanw

NSNull is the only option for objc I guess since we can't put void in box

nmtitov avatar Nov 10 '22 18:11 nmtitov

to get the full value of https://github.com/Snapchat/djinni/pull/116 we really need to get a void type, otherwise it's painful to interop coroutines that return void with djinni futures that can't

bkotsopoulossc avatar Nov 17 '22 20:11 bkotsopoulossc