[nem-en] recursive types

Michal Moskal malekith at pld-linux.org
Thu Sep 23 09:57:35 CEST 2004


On Wed, Sep 22, 2004 at 06:59:33PM +0200, Michal Moskal wrote:
> > 3. Why following declarations are not equivalent:
[...]
> 
> This is a bug. There should be no possibility of getting public
> constructor in the variant class. Public ctors should be allowed only in
> variant options.
> 
> However back to your problem, if the Tree class had Tree() and Tree(int)
> ctors, then Node would have Node(Tree, Tree, object) and Node(int, Tree,
> Tree, object). However in the second case, there is some automagically
> created ctor, that messes things up.
> 
> Could you please report it in our bug tracker, so we don't loose it?

Kamil and I fixed this particular issue yestarday (we're on CSL, so
we're not quite as responsive ;-), but we found two other problems.
There should be no way to construct instances of the Tree() class, but this 
is achieved with an 'abstract' modifier, implicit on variant classes.
However the problem is that our compiler doesn't seem to check for
abstract, so this is another bug. I'll handle it today I guess.

Anyway what we did, was removal of implicit [Record] macro placed on
varaint classes. Variant option still have the [Record] macro placed on
them.

The [Record] macro adds record-like constructor.

[Record]
class A : B { x : int; y : string; }
==>
class A : B { x : int; y : string; 
public this (x : int, y : string) { this.x = x; this.y = y; }
}

However if the base class B had this(f : float) constructor in addition to
this(), then

public this (f : float, x : int, y : string) 
{ base (f); this.x = x; this.y = y; }

would be also added.

The second problem was some internal issue with ordering of the Record
macro and implicit empty ctor creation.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?




More information about the devel-en mailing list