[nem-en] Macro proposal

Kamil Dworakowski kamil.dworakowski at googlemail.com
Tue Jun 19 23:00:12 CEST 2007


Kamil Skalski pisze:
> 2007/6/19, Kamil Dworakowski <kamil.dworakowski at googlemail.com>:
>> Or maybe this would be more self descriptive and more general.
>>
>> def sum = function_with_callback(1, 2,_) <| fun(l, r)
>>     l + r
>>
>> def sum = function_with_callback(1,_,_) <| 2 <| fun(l, r)
>>     l + r
>>
>> Could be implemented as a plain operator(?)
>
> I don't think - mainly because operators cannot inject additional
> parameters into one of its arguments (even assuming it could be
> checked that the argument is a function call).
> Type of such operator is another story.
function_with_callback(1, 2,_) is a curried function

and

fun(l, r)
    l + r
 
is an object

The operator <| can be defined as binary operator taking a function on 
the left and an arbitrary object on the right. This would be symetrical 
to the |> operator defined in lib/internal-numbered.n.

  public static @|> (a : 'p1, fac : 'p1 -> 'r) : 'r
  {
    fac(a)
  }

-- Kamil Dworakowski




More information about the devel-en mailing list