[nem-en] extension methods for local function.

mei mei at work.email.ne.jp
Thu May 4 20:36:05 CEST 2006


Hi,

I tryed to use extension methods for local function. but compile error
occurred.

Is this by design?

-- sample.n
using System;
using Nemerle.Collections;

def foldl (this ls, acc, fn) {
    match (ls) {
        | x::xs => foldl (xs, fn (acc, x), fn);
        | _ => acc;
    }
}

def foldr (this ls, acc, fn) {
    match (ls) {
        | x::xs => fn (x, foldr(xs, acc, fn));
        | _ => acc;
    }
}

def ls = [1, 2, 3];

// compile error !
// there is no member named `foldr' in list.Cons[int-] with type ?
Console.WriteLine (ls.foldl (0, _ - _));
Console.WriteLine (ls.foldr (0, _ - _));

-- 
akiramei <mei at work.email.ne.jp>



More information about the devel-en mailing list