[nem-en] recursive types
Wiktor Zychla
wzychla at vulcan.edu.pl
Thu Sep 23 16:20:18 CEST 2004
thanks, I've already managed to find the () notation. I've adopted the
"ignore(..)" stuff.
as you've noticed, I started the Nemerle adventure with simple Lambda
Interpreter. I will not stop bothering you until I am not finished with it
;)
frankly, trying to get used to Nemerle, I constantly fall into such traps.
The "unbound member" is my favourite. I think that it should be revised or
at last the compiler message MUST explain it better.
now I cannot compile following code. What could be wrong now?
unbound member `DummyName' in type `Lambda'
unbound member `Subsitute' in type `Lambda'
using System;
using System.Collections;
variant Lambda {
| Abs { name : string; term : Lambda; }
| App { term1 : Lambda; term2 : Lambda; }
| Var { name : string;}
static mutable DummyNo : int = 0;
public static FreshName : string {
get {
string.Format( "dummy_{0}", ++DummyNo );
}
}
Substitute( e : Lambda, x : string ) : Lambda {
match( this ) {
| Abs( name, term ) =>
match( name ) {
| x => Abs( name, term );
| _ =>
mutable dummyN = Lambda.DummyName;
Abs( dummyN, this.Subsitute( Var(dummyN), name ).Substitute( e, x ) );
}
| App ( term1, term2 ) =>
App( term1.Substitute( e, x ), term2.Substitute( e, x ) );
| Var( name ) =>
match( name ) {
| x => e;
| any => any;
}
}
}
}
Wiktor
More information about the devel-en
mailing list