Rock currently supports unary minus for literals just fine, but I would like rock to have support for unary plus too :)
glVertex2f(-1, 1) // Works
glVertex2f(+1, 1) // Doesn't work
I'm not sure of the usefulness of this, but there have been a few things I thought would look nicer with an explicit + (like coordinates). Would this work on variables? If so, would it basically just make +a the same as (a > 0 ? a : -a)?
(a > 0 ? a : -a)
I'm pretty much for it. Makes copy/pasting from C OpenGL examples easier ;)
Ok, this sounds easy enough to implement.
@duckinator, I'm not quite sure if +a should be equivalent to a abs(), I'd rather have it the mathematical way, +a == a
Agree with @shamanas here. No funny business, no surprises.
Sounds good to me!
Some languages (including, I believe, C) have the unary + as an upcast (psuedo):
fun foo(short): print "Short"
fun foo(int): print "Int"
foo(+x) # prints "Int"
I don't know ooc/rock well enough to know if this makes sense for ooc. Personally I wouldn't like it - I hate surprises and would rather have the + as a noop (i.e. +a == a).
Noop > upcast, imo.
I'm not sure if we should depart from C's behaviour here...
I don't think having + as type promotion would be a bad surprise for the unknowing: you never lose precision anyway.
However, having + as a noop would be a bad surprise for people coming from C and expecting it to behave the same way.
Alright, after reading various answers in this StackOverflow thread I came to join @duckinator's side (hi nick!) and to say fuck upcasting.
Can we please just get this in as a no-op for the 0.9.8 release?
Work on unary minus, unary plus, unary overload. Closes #518. Closes #…
…484. Closes #724. Closes #725.