# `i` bits shift fo the left
#
# assert 5u8 << 1 == 10u8
- fun <<(i: Int): Byte is intern do return lsh(i)
-
- private fun lsh(i: Int): Byte `{ return self << i; `}
+ fun <<(i: Int): Byte is intern `{ return self << i; `}
# `i` bits shift fo the right
#
# assert 5u8 >> 1 == 2u8
- fun >>(i: Int): Byte is intern do return rsh(i)
-
- private fun rsh(i: Int): Byte `{ return self >> i; `}
+ fun >>(i: Int): Byte is intern `{ return self >> i; `}
# Returns the character equivalent of `self`
#
# REQUIRE: `self <= 127u8`
- fun ascii: Char is intern do return ffi_ascii
-
- private fun ffi_ascii: Char `{ return (uint32_t)self; `}
+ fun ascii: Char is intern `{ return (uint32_t)self; `}
redef fun to_i is intern
redef fun to_f is intern
# `i` bits shift fo the left
#
# assert 5 << 1 == 10
- fun <<(i: Int): Int is intern do return lsh(i)
-
- private fun lsh(i: Int): Int `{ return self << i; `}
+ fun <<(i: Int): Int is intern `{ return self << i; `}
# `i` bits shift fo the right
#
# assert 5 >> 1 == 2
- fun >>(i: Int): Int is intern do return rsh(i)
-
- private fun rsh(i: Int): Int `{ return self >> i; `}
+ fun >>(i: Int): Int is intern `{ return self >> i; `}
redef fun to_i do return self
redef fun to_f is intern
# assert 65.code_point == 'A'
# assert 10.code_point == '\n'
# assert 0x220B.code_point == '∋'
- fun code_point: Char is intern do return cp
-
- private fun cp: Char `{ return (uint32_t)self; `}
+ fun code_point: Char is intern `{ return (uint32_t)self; `}
# Number of digits of an integer in base `b` (plus one if negative)
#
# assert (-10).abs == 10
# assert 10.abs == 10
# assert 0.abs == 0
- fun abs: Int
- do
- if self >= 0
- then
- return self
- else
- return -1 * self
- end
- end
+ fun abs: Int do return if self >= 0 then self else -self
end
# Native characters.
# assert 'A'.code_point == 65
# assert '\n'.code_point == 10
# assert '∋'.code_point == 0x220B
- fun code_point: Int is intern do return cp
-
- private fun cp: Int `{ return (long)self; `}
+ fun code_point: Int is intern `{ return (long)self; `}
# Is `self` an ASCII character ?
#