Safer casts
Yigal Chripun
yigal100 at gmail.com
Tue May 13 04:41:42 PDT 2008
Janice Caron wrote:
> 2008/5/13 Yigal Chripun <yigal100 at gmail.com>:
>> the main thing for me is the syntax:
>> look at Nemerle, for example.
>> Here's a snippet:
>>
>> class MoreFunctions {
>> static run_twice (f : int -> int, v : int) : int
>> {
>> f (f (v))
>> }
>>
>> static run_adder (x : int) : void
>> {
>> def f (y : int) : int { x + y }; // <==== this is a nested function
>> System.Console.WriteLine ("{0}", run_twice (f, 1))
>> }
>>
>> public static Run () : void
>> {
>> run_adder (1);
>> run_adder (2);
>> }
>> }
>
> And the same thing in D:
>
> class MoreFunctions
> {
> static run_twice!(alias f)(int v)
> {
> f(f(v))
> }
>
> static run_adder (x : int) : void
> {
> int f(int y) { return x + y; };
> writefln("{0}", run_twice!(f)(1))
> }
>
> void main()
> {
> run_adder(1);
> run_adder(2);
> }
> }
>
> What's your point?
exactly. the point was for Dee about other languages that provide the
same functionality.
More information about the Digitalmars-d
mailing list