A buffer is a primitive type representing the simplest data form in Simorg. It can hold one or more bytes of data.
A buffer is a raw data type that does not have any specific characteristics. For example, a number can be used in arithmetic operations due to its specific type, but this is not quite true for buffers.
Buffer types are usually representing the chunks of bytes that do not require a specific processing in simorg engine. For example the raw bytes received from a microphone representing audio signals. In these cases we just pass them through.
To define a buffer value literal, use hexadecimal numbering format. For example,
0xff $myBufferVariable // A buffer taking one byte of data [255]
The above code creates a buffer with a single byte of data. To add one extra byte, one can continue adding extra bytes using more hex numbers. It's also possible to separate each numbers using <<<_>>> character for more readability. For example:
0x01ab7763 $fourBytesBuffer // equivalent to 0x01_ab_77_63
Using value <<<0x>>> without any extra hex number, lets us define an empty buffer value.
0x ? // []
0x0 ? // [0]
0x00 ? // [0]
Addition Operator
Using addition operator <<<+>>> between two buffer value will append them together. This is considered a quick syntactic suggar for Buffers.
0x10_20 + 0xff ? // [10,20,ff]
$$$AlertBox type=INFO title=Buffers are always LE message=Buffer values in simorg are considered Little Endian (LE) as to make them more network friendly. $$$
$$$AlertBox type=INFO title=Type Coercion message=Buffers do not participate in any type coercion operation. If they are used with relational operators e.g. equality check, the other value must be a Buffer.$$$
$$$AlertBox type=INFO title=More Utilities message=Simorg stl includes a dedicated library for Buffers, providing more advanced operations.$$$