Safer casts
Dee Girl
deegirl at noreply.com
Tue May 13 07:25:52 PDT 2008
Yigal Chripun Wrote:
> 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.
I do not know Nemerle. But the way run_twice looks it is not parameterized statically. So all calls to run_twice will pass a pointer to function and go to the same body. Many languages do it. It is very different from D run_twice which is parameterized statically. There is big difference.
Also you said I talk about inlining. No. Janice is right. I talk about instantiation.
I write too much but I think I can not explain things well. Maybe better I stop in this discussion. Sorry, Dee Girl
More information about the Digitalmars-d
mailing list