Unary plus and minus 2004-03-13 - By Morten Barklund
Back All,
Anyone also having played around with unary plus and minus:
var a_string = "5"; var a_new_string = a_string; var a_number = +a_string; var a_negative_number = -a_string;
This translates in flasm to:
push 'a_string', '5' varEquals push 'a_new_string', 'a_string' getVariable varEquals push 'a_number', 'a_string' getVariable varEquals push 'a_negative_number', 0.0, 'a_string' getVariable subtract varEquals
That is, there is no such thing as unary plus (I'd expect it at least to do type conversion) and unary minus is subtraction from 0.
Both results are correct of course, but is there any reason for not having the unary operators in bytecode?
And is there any other reason for having the unary plus other than for the completeness of the scripting language, as it is actually stripped from the code when compiling?
// Morten Barklund - currently researching operators in-depth :)
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Supported by Fig Leaf Software =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- Be sure to check the archives and the wiki: http://chattyfig.figleaf.com/ =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106842 =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe send a blank e-mail to: Normal Mode: flashcoders-unsubscribe@(protected) Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|