Noeud « Previous »: T4 FAQ, Noeud « Up »: T4



4.6.7 T4 Improvements

Possible improvements include:

A Runtime class
The Tiger language specify a “standard library” comprising functions such as print, getchar and so forth. This stage requires to know the signature of these builtins to type check their uses, the stage T5 need the signature to implement correctly the call protocol, and some other parts of the compiler might need them.

It is a bad designed that the knowledge about these builtins is scattered in various places, but to avoid departing too much from Appel's modelisation1, we kept it this way. You might want to make one anyway.

More flexibility on the runtime
Maybe the runtime should actually be declared as a form of “prelude”, as Haskell people call it: a file that is always read, initializing the environment. It would contains things such as:
          function substring (string: string, first: int, count: int) : string
            = __builtin "substring"
          /* ... */
     

This would keep all things together, and would make it easier to implement extensions in the language. For instance, one could add:

          function abort () = __builtin "abort"
     

Walking that track goes beyond the simplicity and minimality that the Tiger Projects aims at for (generalist) first year students.


Notes de bas de page

[1] This statement is unfair to Andrew Appel: since in his modelisation type checking and translation are performed in a single step, the information about the builtins remains in a single place.