Basics and values
HollowScript programs are files of statements. There is no main function: the top level of a file is the program. A file can print, compute and return a value, but it can only reach the outside world through a capability it has been granted, such as print. Capabilities are covered properly in Effects and capabilities; for now, uses print at the top of a file is what lets it call print.
uses print
constant greeting = "hello"
variable count = 0
count = count + 1
count = count + 1
effect print("${greeting}, HollowScript ${count}")
effect print("${1 + 2 * 3} ${7 / 2} ${7.0 / 2.0}")
effect print("${true and false} ${true or false} ${not true}")Output:
hello, HollowScript 27 3.5 3.5false true falseA few things to notice:
constantbinds a name once;variablebinds a name that can be reassigned. Neither makes the value itself editable, values in HollowScript are always immutable, only avariablebinding can point at a new one.effect print(...)is a call, marked witheffectbecauseprintis a capability function. The marker is required on every call that reaches a capability, and forbidden everywhere else. See section 9.3.${...}inside a string is interpolation: any expression of typeInt,Float,BoolorStringcan be dropped straight into text. See section 3.9./always divides asFloat, converting both operands first, even twoInts:7 / 2is theFloat3.5, the same as7.0 / 2.0. Integer division and remainder are the library functionsdiv,modandremainder, not an operator. See section 3.4.and,orandnotare words, not symbols, andand/orshort-circuit their right-hand side.
There is no null. An absent value is written none and only exists where an optional type is expected, that is the subject of the next page.