[nem-en] Macros and extension methods
Kamil Skalski
kamil.skalski at gmail.com
Fri Jun 9 17:36:16 CEST 2006
If you want the Select method to be taken from the context of actual
file (the place where macro is expanded), then use
<[ ($collection).$("Select" : usesite) (fun (parameter: $item) { $body }) ]>
otherwise do
using System.Query;
macro @select ...
I guess that you should do the second approach, so writing
select x from ...;
would always mean the same thing, independently of what usings are in
this place.
2006/6/9, Alejandro Serrano <trupill at yahoo.es>:
> 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
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
--
Kamil Skalski
http://nazgul.omega.pl
More information about the devel-en
mailing list