Le Sun, 01 Nov 2009 20:34:56 -0500,
Dave Angel <[email protected]> s'exprima ainsi:

> And from what you said earlier, you WILL need function objects, probably 
> as parameters to the Simulation constructor.  So each instance of 
> Simulation will be given several function objects to specify the 
> distribution functions for the parameters to be used when creating 
> Applicants and Institutions.

A note on "function objects" (because you --Vincent-- seem to regard this 
notion as impressive, but maybe I'm wrong).
In python, function objects are functions, no more; all functions (and methods) 
are objects. Simply, the fact that they are objects, indeed, is revealed in the 
cases where you bind them to a name like any other object.

to an ordinary variable:

if random_choice == GAUSS:
    randomFunc = gaussRandom

or to a func parameter:

def produceDistribution(self, randomFunc, more_param):
    ...
    random_results = randomFunc(more_param)
    self.distrib = Distribution(results)        # if you have type for distrib

This is not so often needed, but your case in the good one.

The feature is present in most high-level languages. But this has not been true 
for a long time, especially for mainstream languages of the "imperative" field 
(while it was more common, even required, for functional languages). So, this 
feature has kept a kind of special prestige and "functions are first-class 
objects" often comes early in a list of language features. But there is nothing 
exceptional in this for a language like python that basically treats data as 
objects, id est that accesses data through references.

Denis
------
la vita e estrany


_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to