-
Notifications
You must be signed in to change notification settings - Fork 40
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
Added support for the null coalescing operator ?? #809
Conversation
Added support for the null coalescing operator ?? Closes #627
No one updated https://github.com/fasterthanlime/nagaqueen, did they? |
Wait, it was added in... um. I don't know what I was thinking, this is over a year old and so is the commit in NagaQueen. Forget I said anything :P |
Haha no worries, I missed the Nagaqueen.c diff too for a bit and was wondering if it was pushed before it got implemented in rock ^^ |
@davidhesselbom I think there is a double evaluation bug with it still, I'll take a look at it right now (I think I naively translated |
You did... honk: func -> Bool { println("honk"); true }
toot := honk() ?? false prints
but it should only print the word once. |
Also, your test includes this line: if ((1 ?? 2 ?? 3) != 3) which gives me the following warnings:
|
Huh, interesting how the operator works with bool too, probably because I actually translate to Translating to a_temp : typeof(a)
... (a_temp = a, a_temp ? a_temp : b) ... Should do the trick, grabbing a coffee and going to town :) Edit: actually, the != null comparison is there, your honk example compares a Bool to a Pointer, which apparently passes right through rock, and true == 1 != null, so it seems to work with bools too :P |
I don't get warnings on my test but I could see how you would if you ignore the overload operator ?? (l, r: Int) -> Int { r } In which case you are comparing integers to null, thus "cast from pointer to integer of different size" |
Ah, yes, I did, I just took that one line from the test file. That explains it. |
Should be somewhat better to use now! |
No description provided.