[nem-en] recursive types

Wiktor Zychla wzychla at vulcan.edu.pl
Thu Sep 23 12:52:59 CEST 2004


> Pattern variables need to be lowercase[1]. The error message should be
> improved, so it's again a bug -- please report it.

1. again, what's wrong with above code?

using System;

variant Lambda {
 | Abs { name : Id; term : Lambda; }
 | App { term1 : Lambda; term2 : Lambda; }
 | Id { name : string; }
 }
}

class Hello
{
 static Main() : void
 {
  mutable l = Abs( Id( "x" ), App( Id( "x" ), Id( "y" ) ) );   // error
  Console.WriteLine( l );
 }
}

in arg #1 needed Id got Lambda calling a reference to global symbol 
`Abs..ctor'

does it mean that self-referencing types between branches in the definition 
of a variant variant type confuses the compiler (Id branch is referenced in 
Abs branch)?

2. do you think that it would be it possible to allow:

variant Lambda {
 | Abs { name : string; term : Lambda; }
 | App { term1 : Lambda; term2 : Lambda; }
 | name : string;
[it does not compile]

instead of

variant Lambda {
 | Abs { name : Id; term : Lambda; }
 | App { term1 : Lambda; term2 : Lambda; }
 | Id { name : string; }

and then simply:

    match( this ) {
        | Abs( ... ) =>
        | App( ... ) =>
        | name : string =>
    }

Thanks in advance for your explanation,
Wiktor 






More information about the devel-en mailing list