Re: Rebinding exception declarations

From: skaller (skaller@maxtal.com.au)
Date: Sun Oct 17 1999 - 13:15:04 MET DST


Date: Sun, 17 Oct 1999 21:15:04 +1000
From: skaller <skaller@maxtal.com.au>
To: Pierre Weis <Pierre.Weis@inria.fr>
Subject: Re: Rebinding exception declarations

Pierre Weis wrote:

> > Actually, I think there is a more syntactic problem: ocaml uses
> > special 'kinds' of bindings, for some reason that escapes me:
> >
> > type X = ..
> > class X = ..
> > exception ..
> > let X = ..
> > let rec X =
> > module X =
> >
> > which permit recursion with an 'and' option. Unfortunately,
> > this syntax does not permit these kinds of bindings to be
> > mutually recursive (quite aside from the semantic issues).
>
> Not aside from, but due to semantic issues.
>
> > I find this syntax strange, I would have expected
> >
> > let X =
> >
> > be enough for all kinds of bindings, determined by the
> > kind of the right hand side.
>
> I understand: you start everything by let and then distinguish the
> construction you are using by some keyword to determine the kind of
> the right hand side. It would ressemble something like:
>
> let x = type ..
> let c = class ..
> let E = exception ..
> let M = module ..
> let _ = .. (for expression only)
>
> I think the regular syntax of Caml is simpler and more intuitive.

        But if that is the only argument, then your
previous claim:

> Not aside from, but due to semantic issues.

is not quite correct.
 
> Apart from syntax, once more it is a semantic problem: modules are not
> values, values are not types, exception are not classes, classes are
> not functors. We prefer to have a direct reflection of these semantics
> distinctions in the syntax: we hope it may induce a clear distinction
> in the programmer's ideas.

        I accept the intuition, but this leaves the problem
that recursions between say, a class and an algebraic type,
cannot be expressed directly using the 'and' option.
Had the syntax been:

        let class X = ..
        and class Y =

we could have added

        and type algebraic = ..

There are cases where this can be proved to work.
For example, by first abstracting the algebraic
types out of the classes (making them type parameters),
then declaring the algbraic types, and then
instantiating the classes with the appropriate
types. I'm not certain, but it seems this is general,
so that mixing class and algebraic types recursively should
be OK .. if only there were a syntax for it.

-- 
John Skaller, mailto:skaller@maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:27 MET