|
 |
Invisible wrote:
> Don't forget Smalltalk. (Although Smalltalk still requires you to write
> them *in the right order*.)
*And* it doesn't tell you in advance when you get it wrong. :-)
Try Ada. :-)
> Yeah, actually _any_ function that requires 8 distinct arguments is
> probably a bad idea.
For OO, you should probably be setting them as configuration-style data on
the object you're invoking. This is Bertrand Meyer's take on it, and it
makes sense to me: if you have a method in an OO language that has optional
arguments, those arguments ought to be properties on the object with setters
and getters. I think this is probably true, because 95% of the time I wind
up with optional arguments, it's because I already wrote and used the
function in a bunch of places, and now I want to pass one more argument
without tracking down all the places the original got called. Either making
it a method with a settable parameter in the instance, or actually taking
the time to track down all the calls (which can be messy in a very dynamic
language) would fix that.
For functional, I can easily imagine a main loop sort of thing having to
carry around a bunch of arguments that don't make sense to put together.
For example, I have a computer word game where the main game-engine keeps a
list of possible guesses, a list of the computer's past guesses, a list of
new words it learned this game, a list of guesses made by the player and
their associated score, the human's previous guess, the computer's previous
guess, the computer's secret work (which the human is trying to guess), the
original list of words, the connection to the UI, and the random number
seed. It's hard to believe there's any data structure that sensibly
encapsulates all that without simply being a kludge to work around the lack
of loops in the language. (With loops, you'd just make most of them local
variables and not actually have to pass them through the recursive calls.)
Mind, I'm not used to functional programming, so maybe I'm doing something
wrong...
--
Darren New, San Diego CA, USA (PST)
The NFL should go international. I'd pay to
see the Detroit Lions vs the Roman Catholics.
Post a reply to this message
|
 |