[nem-en] recursive types

Kamil Skalski nazgul at nemerle.org
Thu Sep 23 16:38:50 CEST 2004


On Thu, Sep 23, 2004 at 04:20:18PM +0200, Wiktor Zychla wrote:
> 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'

There is only FreshName in your code...

> unbound member `Subsitute' in type `Lambda'

Should be Substitute, not Subsitute

> 
> 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 
> 
> 
> 
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en




More information about the devel-en mailing list