[nem-en] Nemerle meets Linq

Michal Moskal michal.moskal at gmail.com
Sun Jan 29 12:57:10 CET 2006


On 1/29/06, Alejandro Serrano <trupill at yahoo.es> wrote:
> > or something like that. Maybe even:
> >
> >   syntax("orderby", expr, Optional(desc))
> >
> > and check if desc is <[ descending ]>, <[ ascending ]> or whatever.
> >
> > I don't know if this is what you meant.
> >
> >
> The problem is that the parsing is for each order sequence, maybe:
>
> |> orderby [(_.Country), (_.Telephone) descending]

It may be possible to use:

  syntax ("orderby", expr, Optional(rest))

(this doesn't take care of desc/asc), and later do:

  def x = <[ System.Query.OrderBy (...$expr...) ]>
  match (rest)
    | Some (rest) => <[ $x |> $res ]>
    | None => x

That is to make the 'rest' eat rest of the arguments (next
orderby/where/whatever clauses).

> > We once had an idea to include Nemerle.Core.identity or something like
> > that. 'x => x' once we have this syntax also won't be bad.
> >
> A syntax like x => x.Telephone is really good
>
> Well, the C# is a bit cleaner, but I think this Nemerle-like one is
> better for extension. In fact, we would not need extension methods for
> this, because |> can be used as it. However, I don't know whether:
>
> [1, 2, 4, 3, 7] |> where _ > 3
>   |> orderby _
>
> or
>
> [1, 2, 4, 3, 7] |> where x => x > 3
>   |> orderby x => x
>
> looks better. Any more ideas?

We wanted 'x => expr' to be the same as 'fun (x) { expr }' in the entire
language, not just LINQ. So the user will be free to choose
'x => x.Something' vs '_.Something'.

--
   Michal Moskal,
   http://nemerle.org/~malekith/



More information about the devel-en mailing list