digitalmars.D  Function pointers/delegates
 S (4/4) Nov 29 2007 real function(real x) y = function real(real x) { return sqrt( 1  x * x...
 Johan Granberg (2/10) Nov 29 2007 Agreed I always get this wrong and has to correct compiler errors.
 Jason House (2/14) Nov 29 2007 Same here.
 Craig Black (4/11) Nov 29 2007 I like the way C# 3.0 does anonymous functions. I believe the idea come...

Don Clugston
(3/20)
Nov 29 2007
I like the way D does anonymous delegates.
real function(real x) y = function real(real x) { return sqrt( 1  x * x ); }; Is it just me or does it seem odd that real and function are swapped on one side? I can kind of see this if it's for singlepass parsing, but isn't there a better way? It's not intuitive at all.
Nov 29 2007
S wrote:real function(real x) y = function real(real x) { return sqrt( 1  x * x ); }; Is it just me or does it seem odd that real and function are swapped on one side? I can kind of see this if it's for singlepass parsing, but isn't there a better way? It's not intuitive at all.Agreed I always get this wrong and has to correct compiler errors.
Nov 29 2007
Johan Granberg wrote:S wrote:Same here.real function(real x) y = function real(real x) { return sqrt( 1  x * x ); }; Is it just me or does it seem odd that real and function are swapped on one side? I can kind of see this if it's for singlepass parsing, but isn't there a better way? It's not intuitive at all.Agreed I always get this wrong and has to correct compiler errors.
Nov 29 2007
"S" <S s.com> wrote in message news:fin4j6$1hks$1 digitalmars.com...real function(real x) y = function real(real x) { return sqrt( 1  x * x ); }; Is it just me or does it seem odd that real and function are swapped on one side? I can kind of see this if it's for singlepass parsing, but isn't there a better way? It's not intuitive at all.I like the way C# 3.0 does anonymous functions. I believe the idea comes from Nemerle. It would be something like: real function(real x) y = real <= (real x) { return sqrt(1  x*x); };
Nov 29 2007
Craig Black wrote:"S" <S s.com> wrote in message news:fin4j6$1hks$1 digitalmars.com...I like the way D does anonymous delegates. <g> real delegate(real x) y = (real x) { return 1  x * x; };real function(real x) y = function real(real x) { return sqrt( 1  x * x ); }; Is it just me or does it seem odd that real and function are swapped on one side? I can kind of see this if it's for singlepass parsing, but isn't there a better way? It's not intuitive at all.I like the way C# 3.0 does anonymous functions. I believe the idea comes from Nemerle. It would be something like: real function(real x) y = real <= (real x) { return sqrt(1  x*x); };
Nov 29 2007