[Python-Dev] Simple Switch statementZ (original) (raw)

Ka-Ping Yee python-dev at zesty.ca
Mon Jun 26 02:43:27 CEST 2006


On Sun, 25 Jun 2006, Guido van Rossum wrote:

What do you think of Nick C's 'once'?

It's a bit closer to the right meaning... but what about:

def f(x):
    def g(y):
        return y + once x
    return g

Does "once" mean not really once here, but "once for each new function object that's created for g"?

Right. But there are all sorts of objects that are compared by object identity (e.g. classes, modules, even functions) which may contain mutable components but are nevertheless "constant" for the purpose of switch or optimization. Let's not confuse this concept of constness with immutability.

That's a good point. We need a concept like "stable for equality" separate from "constant", since "constant" and "immutable" will mislead those who are used to the meanings of these words in other languages.

-- ?!ng



More information about the Python-Dev mailing list