[nem-en] Macros and extension methods

Alejandro Serrano trupill at yahoo.es
Fri Jun 9 17:31:54 CEST 2006


I'm trying to emulate the C# 3.0 behaviour in query expressions, where 
"from item in collection select item > 2" is converted to 
"collection.Select(item => item > 2)", taking the Select method from the 
context of the actual file. Is there any way to do it? If not, I'll just 
adhere to the canonical System.Query implementation (but not emulate C# 
3.0).

Thanks

P.S.: I'm using this macro. Is it correct?

macro @select (clause, body)
  syntax ("from", clause, "select", body)
  {
    def (item, collection) =
      match (clause) {
        | <[ $i in $c ]> => (i, c)
        | _ => Message.FatalError ("bad syntax");
      };
     
    <[ ($collection).Select (fun (parameter: $item) { $body }) ]>
  }

Kamil Skalski escribió:
> Probably the problem is that you don't have 'using System.Query;'
> specified in the place the macro is defined. Remember, that the global
> context is taked from the place where you write the macro, not from
> the place it is expanded.
>

		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com




More information about the devel-en mailing list