Argentum was initially designed as 64bit-only language. Its integer and floating point types were 64bit (int
and double
types respectively) while support for all other data types was limited to raw buffer operations through Blob
data type - it allowed indexed access to 8, 16, 32 and 64-bit data.
Unfortunately not all platforms are 64bit yet. There are 32bit controllers, and nowadays WASM is 32bit. Also the absence of 32bit data types creates complexities with integration to multiple platform libraries. For example most 2D and 3D GUI and graphics libraries use 32bit floats and integers for coordinates, and ARGB colors are mostly 32bit. That's why Argentum got the experimental 32bit types.
The following changes are made: now Argentum is 64bit-first language with full 32bit support.
New types
In addition to 64bit int and double types there added:
short
- 32bit integerfloat
- 32bit floating point.
New constants
Since Argentum numeric constants define both value and type, there were added two suffixes (f
and s
):
3.14f
- a 32bit floating point (float)2f
- also 32bit floating point-3.14e-1f
- also 32bit floating point in full exponential form.0s
- a 32-bit integer (short)0xffffs
- also a 32bit in hexadecimal
32-bit constants are limited to:
- 31 significant bits - if decimal - (apply unary minus to change sign if needed)
- 32 significant bits - if binary, octal, hexadecimal
Constants without suffixes define 64bit values as before.
Operations
- unary bitwise inversion (~) when applied to
short
, produceshort
, when applied toint
- produceint
- unary minus is applicable to all numeric types; it produce the result of the same type
- binary operations
+-*/
are applicable to all numeric types; they require both operands to be of the same type and produce result of the same type - binary bitwise operators
<< >> & | ^
applicable toshort
andint
; they require both operands to be of the same type and produce result of the same type - comparisons
< > <= >= != ==
applicable to all numeric types and require operands of the same type; producingbool
.
All integers operations are defined in 32 or 64 bit two's complement arithmetic.
Conversions
There are no automatic conversions between numeric types. All conversions should be performed explicitly:
int(expr)
- converts expr to 64bit integer:- if expr it
short
(32bit) - it performs sign-extension - if expr is
float
ordouble
, it converts floating-point value to 64bit int
- if expr it
short(expr)
- converts expr to 32bit integer:- from
int
(64bit) - it truncates higher bits - from floating-point type - it rounds fractional part and truncates higher bits
- from
float(expr)
- convertsint
,short
,double
tofloat
double(expr)
- convertsint
,short
,float
todouble
.
Blobs
set8At
,set16At
,set32At
- take 32bit (short) valuesget8At
,get16At
,get32At
- return 32bit (short) resultsputChAt
- takes 32bit code-point
Strings
Now all character code-points are 32bit:
Cursor.getCh
,peekCh
- return 32bit code-point- built-in macro
utf32_(expr, expr,...)
expects 32bit code points - Character constants
'H'
- produce 32bit character code (short)
Changes
Modified code:
- compiler
- runtime library
- ag - modules (string.ag etc.)
- SDL bindings
- graphic scene
- all affected demo apps.
Readiness
So far 32bit support exists only for Argentum built from sources.
It is not yet presented in the playground and Windows-Linux demo.