[nem-en] Re: Macro proposal
Kamil Skalski
kamil.skalski at gmail.com
Thu Jun 21 09:22:37 CEST 2007
That is right, we will not have Ruby blocks this way, but I like their
syntactic form. Maybe we could use 'do' keyword-operator for your
macro?
def sum = function_with_callback(1, 2) do (l, r) =>
l + r
2007/6/20, Elifant <elifantu at mail.ru>:
> Kamil Skalski пишет:
> > Ah, so actually <| would be equivalent to function application...
> > So, right, this should be possible too. What macro could do here is to
> > transform the right hand side from expression to lambda, so you could
> > write
> >
> > f (1,a) <| 3
> >
> > and it would be transformed into
> >
> > f (1, a, fun () { 3 })
> >
> > which probably would bring us even closer to Ruby blocks ;)
> >
> > f(1,a) <| {
> > foo ()
> > }
>
> In general, lambdas will accept parameters, and IMHO it is better to use
> usual fun(a,b) { ... }
> instead of trying to mimic Ruby's {|a,b| ... }.
> BTW, blocks in Ruby are more than just lamdas, e.g. 'return' statement
> inside block will return from
> enclosing function, not from the block. I think it is possible to
> implement blocks in Nemerle, but
> their behaviour may be too suprising for anyone besides Rubyists.
>
>
> _______________________________________________
> https://nemerle.org/mailman/listinfo/devel-en
>
--
Kamil Skalski
http://nazgul.omega.pl
More information about the devel-en
mailing list