How to extend Nemerle with C# function that takes arguments?

167 views Asked by At

I want to create a function like public static int Sum(int a, int b){ return 0; } (in C#, not nemerle) that would be inside .n document (not external dll) and be visiable for nemerle code. How to do such thing? (cant find examples on the web)

2

There are 2 answers

3
Ziav On

Nemerle allows class name in the using keyword for import static class methods.

module Functions {
    public Sum(a : int, b : int): int { a+b }
}

// or 
class Functions2 {
    public static Mul(a : int, b : int): int { a*b }
}

using Functions;
using Functions2;
using System.Console;

module Program
{
  Main() : void
  {
    WriteLine(Sum(2, 3));
    WriteLine(Mul(4, 5));
  }
}
0
user299771 On

No. But you can create a partial class. One part of the class can be written in Nemerle, and other in C#.