[nem-en] HowTo: determine new expression?

Kamil Skalski kamil.skalski at gmail.com
Wed May 2 19:38:59 CEST 2007


The simplest way is to check if given PExpr is a type name:

 Nemerle.Compiler.Macros.IsTypeName (e : PExpr) : bool

though this is not the best compiler can do in general. In standard
compilation this is handled by overloading resolution, which checks
for type's accessibility and even the expected type to be returned by
expression, like:

class bar {}

module Test {
 foo1(x : bar) : void {
  System.Console.WriteLine (x);
 }
 foo2(x : string) : void {
  System.Console.WriteLine (x);
 }
 bar () : string { "halo" }

 Main () : void {
  foo1 (bar())
  foo2 (bar())
 }
}

which can be resolved only by running the typer (at best in delayed
mode, so it also considers type inference).

2007/5/2, Ivan A Eryshov <ivan.eryshov at gmail.com>:
> test.n
> <code>
>   SomeMacro(object()); // creation of new object
>   SomeMacro(meth()); // calling of method
> </code>
>
> macro.n
> <code>
>   macro SomeMacro(expr)
>   {
>     // I need ot understand is constructor of method is called. How?
>   }
> </code>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>


-- 
Kamil Skalski
http://nazgul.omega.pl



More information about the devel-en mailing list