What Gont is meant to be?
=========================

Largly imperative composition of C-like lexical layer, control structures
and speed with ML's typesystem, functions as first class citizens,
and safty. Plus possibly few more things, like objects.


Concepts
========

Typesystem
----------

Basic types: int, float, string, bool, void. 

Function type is defined as follows:

  [t1, t2, ..., tn] -> t
  
where n >= 0. One might note that this is somewhat diffrent from ML where
all functions take just one parameter (which can be typle or another
function, but this is not the point). This is closer to C's function
notation.

Other types include tuples, structures, unions (that will be roughly
eqivalent of ML's datatypes) and arrays.


Constructing functional values
------------------------------

There are two ways to build functional value in Gont. First comes from C:

  int add(int a, int b) { return a + b; }
  
and the second from ML:

  [int, int] -> int add = fun [int a, int b] -> int { return a + b; };

The second way might seem odd to C programmer. Of course, becouse it is
odd when used to define simple C-like function. But it is not when you
need to pass function to another function, let's say:

  void fputs(file f, string s);
  ...
  void do_sth(int foo, [string] -> void err_report);
  ...
  do_sth(16, fun [string s] -> void { fputs(f, s); } );

People familiar with ML might recognise that despite the type information
for (fun ...) statement can be obtained from itself, it still has to be given
(even twice). I guess it is place for experiments.

I also would like to have some support for named arguments, so functions
can be called as:

   Window.create(width => 20, height => 23, color => red);

This should come with default values.


Argument passing conventions
----------------------------

All this discussion applaies to compiler only. It has nothing to do
with actual gont language use.

Values passed as polimorphic parameters has to be all of the same size.
Otherwise we wouldn't be able to generate efficient code. Specially for
this purpouse `int' gont type is choosen with the same as size as machine
pointer. (This is not the choice of some C compilers on some 64 bit
architectures, for example on alpha-linux with GCC sizeof(int) = 4, 
sizeof(long) = sizeof(void*) = 8). 

They are few basic types of passing arguments in gont. 

1. by value. int and bool are passed this way.
2. by pointer to some location on the heap. objects are passed this way.
3. by pointer to location, that is not guaranted to exists after function
   terminates (read: this can be pointer to the stack of
   function that called us). If such value needs to be saved after function
   return, is has to be copied to the heap. It also has to be copied if
   calling raise with it. Special functions are provided by the runtime to
   copy such values. Floats and functional values are passed this way.

Functional values cannot be passed simply as pointers to functions,
since they might need clousre in some (most?) cases. Here is layout of
datastructure describing functional value:

  void *fnc;
  void *closure;

closure has to be passed as the first argument to fnc. Closure musn't 
point into the stack.

One might note that it might be impossible to pass regular function this
way. We might need auxilary function to be genrated.

