Skip to content

Latest commit

 

History

History
67 lines (43 loc) · 1.72 KB

literals.org

File metadata and controls

67 lines (43 loc) · 1.72 KB

Glint’s Literals

A literal is defined as fixed values embedded in the source code. Also known as self-evaluating expressions.

Number Literals

69 420 ;; regular decimal literals
;; 042 ;; ERROR! Leading zeroes not allowed

0b0 0b01000101 ;; regular binary literals
0o0 0o377      ;; regular octal literals
0x69 0xbeef    ;; regular hexadecimal literals

1'004       ;; decimal literal with separator
0b0010'0100 ;; binary literal with separator
0xb0'0b     ;; hexadecimal literal with separator

A number literal is of integer type.

String Literals

A string is a contained sequence of bytes in the source code that is converted into data that is embedded in the final program.

'' 'i am data?' ;; regular string literals

"" "i\'m data?" ;; escapable string literals

A string literal is of array of byte type.

Byte Literals

Sometimes, it’s convenient to get a number representation of a byte in the source code (i.e. 0 or a). Mostly for ASCII math stuff, to be honest, but still needed often enough to be necessary.

`6` `9` `A` ;; regular byte literals

;; `` ;; ERROR! Empty byte literal

Byte literals accept basic escaped values like \n for newline, \0 for NUL, and \\ for \.

Boolean Literals

There are two of them.

true
false

Compound Literals

A way to write a literal of more complex types (like structs).

Just a list of expressions separated by soft separators, with the extra ability to name expressions.

;; regular compound literals
!{}; !{420}; !{420, 69};

;; compound literal with named expressions
!{.value 420}; !{.x 420, .y 69};