-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Currently, in AddAmbientMethods, we add quality-of-life functions that depend on authority. In a teaching context, this allows students to get started using Troupe without getting confused by too many new concepts at once (think static void main in a class in Java).
We would like to make this preamble (1) easier to maintain, (2) easier to swap out, and (3) possible to omit such that only the core language is available ( see also #64 ). To this end, we would like to have the following io.preamble.trp file:
let fun printString x = fwrite (stdout authority) x; fwrite (stdout authority) "\n"
fun print x = printString (toString x)
fun printL x = printString (toStringL x)
fun inputLine () = freadln (stdin authority)
in ()
endSimilar to AddAmbientMethods we would, after parsing (and other validation?), replace the in () end with in <program> end.
The compiler would be provided a new flag --include-preamble/--prefix (short -ip/-p?) which takes the given file(s), parses them, and prepends them on the given program.