Data Types - GordianNaught/Juicy GitHub Wiki
Currently Juicy supports 4 data types intrinsicly: int
, bool
, ascii
, and byte
.
The planned intrinsic types are int
, bool
, ascii
, byte
, float
, and utf32
.
- int
- 64 bit signed integer type
- float
- 64 bit floating point value
- bool
- value signifying true or false
- currently 64 bit on a register
- plan to pack them to 1 bit each in vectors
- size on the register really doesn't matter as all values are passed on registers anyways
- utf32
- 32 bit unicode code point
- ascii
- 8 bit ascii value
- byte
- 8 bit value
Casting
Casting does not have a special syntax, and casting is accomplished with a function that is the name of the type you would like to coerce a value to. Because functions can be overloaded, casting from different types can be implemented.
As an example, this converts the integer value 97
into a byte, and then the byte
into the ascii letter a
.
ascii(byte(97))
Because casting from an integer to a byte is intrinsic, and casting from a byte to an ascii is intrinsic, we can implement casting from an integer to an ascii ourselves.
ascii(int n) = ascii(byte(n));
After this has been implemented, we can cast to an ascii from an int directly as shown here.
ascii(97)
Intrinsic Base Types
Intrinsic types are types known by Juicy without implementation by the programmer. Base types are not passed by reference, and thus since Juicy compiles to x64, base types make the most sense if they can fit on a 64-bit register.
Currently, intrinsic base types must be implemented as detailed in Contribution.
There are plans to allow intrinsic base types to be implemented in Juicy code
directly. When this happens there will be no need to dig into the source code
of Juicy to implement a new type like utf8
for example.