Version 1.6
The objective for FISh 1.1 was to improve the user syntax of the
language. Programs may now employ explicit types for term variables
and terms. As well as being a useful form of annotation, they allow
the second major change: many of the syntactic novelties imposed by
the introduction of shapes have been elided, as have most of the
explicit coercions and the variant forms of conditional. Usually, the
compiler is able to determine when a constant, e.g. 3 is to
be treated as a size, and when it is to be treated as an integer. In
the remaining cases, it suffices to insert a type into the code. These
two changes, and other minor syntactic changes are examined in the
subsections below. Here are the other noteworthy changes.
Empty arrays are now supported, e.g. fill {2,0:int_shape} with
[].
Many basic operations are now ad hoc polymorphic, i.e. "+" can be
applied to floats and "=" to booleans.
The function equal for equality of shapes has been replaced
by the in-fix operator #=.
A datum type of characters has been introduced. Standard string syntax
has been adopted for vectors of characters.
Expression blocks can now be used for indices to both variables and
expressions, e.g.
x[newexp int_shape (fun i -> i:= 0)]
has the same value as x[0] regardless of whether x
is a variable or expression. This is rather delicate, as enlarging the
scope of i to include x escapes the current
formalism of newvar and newexp. The current solution
is not necessarily compatible with future language developments, and
so is not provided as part of the user syntax.
The combinator "ap2exp" was originally introduced to allow the
programmer to flag certain compile-time optimisations. These are now
fully automated (with no loss of performance) and so the combinator
has been replaced by a function of the same name in the standard
prelude.
Some users of the byte code version had difficulties with the C
library. Wolfgang Gherke has produced a linux version of libfish.a.
Many other minor changes have been effected along the way, and some
bugs have been fixed.
Explicit Types
Any variable x or term t may now be given an
explicit type theta. The syntax is
(x:theta)
(t:theta)
The brackets are obligatory. The exp keyword may be elided
from constant types, e.g. (x:[int]) for (x:exp
[int]) but is required for variable types to distinguish array
type variables from phrase variables. Here are some examples.
>-|> let f x = (x:size) +1;;
f : size -> size
>-|> let f (x:size) = x+1;;
f : size -> size
>-|> let g (x:var a) = get x;;
g : var [a] -> var a
>-|> let h (x:exp a) = get x;;
h : [a] -> a
Syntactic Simplification
The following combinators, constants and forms have been dropped from
the core language.
-
"~" forms of terms, e.g. "~3", "~+"
-
The coercions "size2int", "fact2bool" , "dock2float" , "@" , "var2exp"
-
"condexp" and "condsh", and the corresponding "ife" and "ifsh" forms
(use the standard conditional forms)
-
"getexp" and "subexp" (use "get" and "sub" - see "sub" below)
-
"ap2exp" (now a defined term of the standard prelude)
-
";" as a separator for declaration lists and binder lists (now use
"and", though with no change to the order of dependency.
-
"/" (renamed "div" to distinguish from division of floats)
-
"ledexp"
Other Syntactic Changes
-
term variables and terms may be typed
-
the comparisons "=","<","<=",">",">=" act on any datum type.
-
the operations "+","*" and "-" act on both integers and floats.
-
the type stat float has been renamed cost.
-
the constant "char_shape" has been added
-
string syntax (for arrays of characters) is supported.
-
"skip" may be elided from any form requiirng a command.
-
"sub i x" is now "sub(x,i)" where x is of array type and
i is the index. Typing now depends on that of x.
Also, the restriction that local variables not appear within array
indices now extends to array expressions as well as array variables.
-
binary mathematical functions are now written in-fix.
Versions 1.2 - 1.3 were mainly internal re-organisation, for greater
clarity, to make checking against the formal definition easier, and to
insert explicit shape-to-data-coercions during type inference.
Version 1.4 introduced mode switches that allow some of the
optimisations described in the formal definition to be switched
off. This is useful for theoretical explorations. The syntax is
%show [+-] xxx_opt ;;
The + or - switches the optimisation on or off. The possible
optimisation modes are
- infer
- loop_opt
- datum_opt
- assign_opt
There is also a mode "parse" for seeing the parsed code. Any prefix
of a mode (except assign) can be used in place of the whole name.
Note that you can now view a program through each stage of its
transformation, from parsing, and the inferred term, through various
levels of partial evaluation, to the turbot code (%turbot) to the C
code.
The translation to C has been completely revised. In earlier versions
multidimensional array parameters in general recursion did not behave
properly under translation. The new translation represents every array
as a one-dimensional C array, using pointer arithmetic in FISh to
determine offsets. Some comments have been added to the C code to help
interpret these offsets. More may be added in future. Now quicksort
will work with arrays of arbitrary dimension. However, the translation
still does not work correctly in the comparatively rare situation of
general recursion with proper arrays as parameters to the recursive
function. This will be addressed in the near future.
Page Last Updated: Wednesday, 04-Nov-1998 19:38:56 EST
|

Main |
Announcement |
Latest Paper |
Distribution |
Tutorial
Ready Reference |
Benchmarks |
Designer
Please feel free to send any comments.
Copyright Barry Jay © 1998
|