Spoiled
2005-04-22 22:59:19.574395+02 by
Dan Lyke
6 comments
Augh. I've been spoiled by Python and Perl: I'm missing a convenient lambda facility in C++. Function pointers would make the code harder to read, but I'm on my fifth "iterate over this list in a slightly weird way and do ..." idiom.
[ related topics:
Perl Software Engineering Python
]
comments in descending chronological order (reverse):
#Comment Re: made: 2005-04-23 19:42:43.692521+02 by:
Dan Lyke
Hmmm... Thanks for the reminder about templates, I'll go refresh myself.
The main concern with any external encapsulation, be it function pointers or classes with methods is that they'd pull the code out of the flow. Templates, on the other hand...
#Comment Re: made: 2005-04-23 17:17:38.90676+02 by:
aiworks
If function pointers would solve the problem at the expense of usability, why not use function objects? Better yet, if iterating over lists different ways is the issue, look at the built-in STL function objects (there's lots of wonky container iteration options).
#Comment Re: made: 2005-04-23 13:30:34.982912+02 by:
DaveP
Tried Boost? Boost Lambda works in almost all C++
compilers.
#Comment Re: made: 2005-04-23 11:35:44.971325+02 by:
meuon
I have only used eval a few times in Perl,
and yes, am very wary of self-modifying code (I've blown it up some).
And have not yet needed such functionality in my PHP projects.
But that same comment said "Chessmasters can do it because they know what they're doing. Beginners and intermediates, however, are quick to attack (use it) without recognizing the long term danger.".
I'll consider Dan a chessmaster doing things that would probably work well if
he was using a lambda facility....
#Comment Re: made: 2005-04-23 04:16:33.214579+02 by:
ebwolf
And the comments from meuon's link:
"Basically, if create_function() is the answer, you arn't asking the right
question"
Beware self-modifying code! I could see Perl providing this kind of functionality and I guess PHP and Python have to follow in step. And Dan has obviously taken quite a breather from C/C++ if he thinks "function pointers would make the code harder to read".
#Comment Re: made: 2005-04-22 23:48:18.406314+02 by:
meuon
Wow.. I learned something. And found PHP Fakes this functionality a bit with create_function()
http://us4.php.net/create_function
We will not edit your comments. However, we may delete your
comments, or cause them to be hidden behind another link, if we feel
they detract from the conversation. Commercial plugs are fine,
if they are relevant to the conversation, and if you don't
try to pretend to be a consumer. Annoying endorsements will be deleted
if you're lucky, if you're not a whole bunch of people smarter and
more articulate than you will ridicule you, and we will leave
such ridicule in place.