Skip to content

literals

Dr. Nicola Mingotti edited this page Dec 11, 2021 · 1 revision
  • This page content is taken from TerseGuide -> Literals.
  • There is some extra formatting, there might be additions respect to the original.
" ---- Fundamentals
" 
b _ true.			"true pseudo-variable"
b _ false.			"false pseudo-variable"
x _ nil.			"nil object pseudo-variable"

" ---- Numbers 
" 
x _ 1.				"SmallInteger literal"
x _ 3.14.			"Float literal"
x _ 2e-2.			"Fraction literal"
x _ 2.0e-2.			"Float literal"
x _ 7/8.			"Fraction literal"

" ...
"
x _ 16r0F.			"SmallInteger literal".
x _ 16rFFFFFFFF.		"LargePositiveInteger literal".
x _ 16rFFFFFFFF negated.	"LargeNegativeInteger literal".
x _ -1.				"negative SmallInteger literal"

" ---- Characters, Strings and Symbols
" 
x _ 'Hello'.			"String literal"
x _ 'I''m here'.		"single quote escape"
x _ $A.				"Character literal"
x _ $ .			        "Character literal (space)"
x _ #aSymbol.			"Symbol literal"

" ---- Array and and other kind of list-like objects
"
x _ #(3 2 1).			"Array literal"
x _ #('abc' 2 $a).		"mixing of types allowed (all literal)"
x _ #[3 2 1 0].			"ByteArray literal"
x _ #[1.0 3.141592 6.02e23].	"Float64Array literal"

" ---- Composed Objects
" 
x _ {'Hello' size. Float pi. 1.0 arcTan }.         "Warning: NOT a literal. Created on each run"
x _ `{'Hello' size. Float pi. 1.0 arcTan }`.       "Backtick syntax. Anything can be a literal!"
x _ `{ 1. 3. 5. 7. 11. 13. 17} asSet`.             "A literal Set"

Dr. Nicola Mingotti last updated on 06-Sep-2021.

Clone this wiki locally