Chapter 6: PolyML.Compiler

This chapter describes the PolyML.Compiler substructure. This structure contains a collection of items which can be used to modify the behaviour of the Poly/ML compiler.

6.1 Compiler flags

val promptl : string ref
val prompt2 : string ref

val useRCS : bool ref
val suffixes : string list ref

val maxInlineSize : int ref
val assemblycode : bool ref

prompt1 is the primary prompt string (default "> ") used by Poly/ML. Assigning a new value to this ref alters the primary prompt. For example:

> PolyML.Compiler.promptl := "a longer prompt";
val it = () : unit
a longer prompt> 1 + 1;
val it = 2 : int
a longer prompt>

prompt2 is the secondary prompt string (default "# ").

useRCS determines whether the Poly/ML make system attempts to make use of the RCS code control system.

suffixes is the list of suffixes (default ["", ".ML", ".sml"]) used by the Poly/ML make system when it tries to find the source file containing an ML functor, structure or signature. (See chapter 7 for more details).

maxInlineSize is used by the Poly/ML optimiser to determine whether a particular ML function should compiled 'in-line'. Each call to an in-line function will be expanded in place which should generate faster (but probably larger) assembly code. Increasing the value of this variable allows more functions to be compiled in-line. Values in the range 10 - 40 tend to produce the most reasonable trade-offs between code size, compile time and execution time.

assemblyCode controls whether the compiler prints an assembly-code listing of each function it compiles. Don't set this flag unless you want to debug the compiler!

6.2 Forget functions

The following functions are provided to deal with the problem of name-space pollution:

val typeNames : unit -> string list
val forgetType : string -> unit
val forgetTypesExcept : string list -> unit

val valueNames : unit -> string list
val forgetValue : string -> unit
val forgetValuesExcept : string list -> unit

val signatureNames : unit -> string list
val forgetSignature : string -> unit
val forgetSignaturesExcept : string list -> unit

val structureNames : unit -> string list
val forgetStructure : string -> unit
val forgetStructuresExcept : string list -> unit

val functorNames : unit -> string list
val forgetFunctor : string -> unit
val forgetFunctorsExcept : string list -> unit

val forgetMakeInfo : string -> unit

val fixityNames : unit -> string list
val forgetFixity : string -> unit

The functions typeNames, valueNames, signatureNames, structureNames and functornames each return a list of strings. This list contains all the names in the corresponding top-level ML name-space. In addition, fixityNames returns the list of identifiers than have been explicitly declared to be infix, infixr or nonfix.

The forgetXXXX functions each remove a name from the corresponding top-level name-space. If the name isn't defined in the top-level name-space, these functions raise a (currently undocumented) exception.

The forgetXXXXExcept functions each remove all the names except those listed from the corresponding top-level name-space.

The function forgetMakeInfo deletes the Poly/ML make system's compilation record for a particular signature, structure or functor. This ensures that the next make of that object will actually recompile it.

Note: the forget functions don't interact well with the database hierarchy, since they can't forget a name that is inherited from a parent database's name-space. In addition, forgetting a name in a child database may reveal a value in the parent database that was previously hidden.

Copyright (c) 2000 CUTS and contributers.  Last updated: 15 January 2002 by David Matthews.