Closed
Description
by sjbogdan:
Need a compiler level support for fast bool to numeric types ( int, byte, float ) conversion. Possible syntax : var flag = false 1) flag.( int ) 2) int ( flag ) Right now, except for "if" blocks, there is no way to make a conversion. It is important for high speed computing with "bit magic". Classic example ( pseudo code ) : if a > 0 { b = sin ( a ) } else { b = 0.0 } Compiler would generate a faster (virtual) assembly code with ( because there won't be jmp* commands ) : b = ( a > 0 ).( float64 ) * sin ( a ) The conversion should be cheap & fast, thus I though about interface-like type transition. The values are always 0 or 1, which might be hardcoded into numeric types definition.