Null<UInt> broken ?

94 views
Skip to first unread message

Chman

unread,
Mar 29, 2014, 5:09:41 PM3/29/14
to haxe...@googlegroups.com
Hello,

Any reason why Null<UInt> throws an error on compilation on cpp target ? Null<Int> and Null<Float> work as expected.

function test(myUInt:Null<UInt> = null)
{
    return myUInt == null ? 0 : myUInt;
}

throws :

On static platforms, null can't be used as basic type Float

Cheers,

ScrambledRK

unread,
Apr 11, 2014, 5:02:43 AM4/11/14
to haxe...@googlegroups.com
can't offer an solution just my compassion (?) 
I ran into troubles using UInt even back in flash and ever since made a huge turn around it and use Int for everything. Even Colors work as Int for some reason although I thought Int would be too small.

Justin L Mills

unread,
Apr 11, 2014, 6:09:33 AM4/11/14
to haxe...@googlegroups.com
UInt is often slower in flash and often results in a Int to UInt to Int
type conversion in real use if you analysis how a value is used.
Vector<Int> seem much much faster than Vector<Float> to the point where
it's often worth timesing an Int value by 100 manipulating it then
dividing it by a 100 to get a Float out thus keeping a bit of accuracy
but making use of the faster Vector<Int> access. Also better for
performance to use a Vector<Int> to hold 2d points than
Vector<Point<Int>> maybe an Abstract can be used to make access simpler.
UInt was added to flash I think mostly as icing for developers from
other languages who expect it, unless stuff has changed for flash target
it's best avoided, for this reason I also avoid UInt on all targets, but
would be interested to know if it makes sense on other targets?

ScrambledRK:

Chman

unread,
Apr 11, 2014, 6:18:19 AM4/11/14
to haxe...@googlegroups.com
I mainly use UInt on CPP and JS target where I expect a variable to only hold an unsigned value. It helps make the API a bit more descriptive for the user.

Andy Li

unread,
Apr 11, 2014, 8:12:24 AM4/11/14
to haxe...@googlegroups.com
Sounds like a bug. I have just reported it to https://github.com/HaxeFoundation/haxe/issues/2871

Best regards,
Andy


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages