[Python-3000] in-out parameters

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sun Apr 30 11:01:59 CEST 2006


"Rudy Rudolph" <rudyrudolph at excite.com> writes:
> def f(inout param):
> param += 5
> return "this is my result"
>> # call it
> x = 2
> result = f(x)
> # x is now 7

In a dynamically typed language it's not going to work unless both
the parameter in the function definition and the actual argument are
marked. Then it's easy, well-defined, and can even support other
"lvalues", e.g.:
def f(ref x):
 x += 1
f(ref a[g()])
# g() is executed once
# reading x does __getitem__
# setting x does __setitem__
I'm not judging whether it's worth having, only how it should work if
supported.
-- 
 __("< Marcin Kowalczyk
 \__/ qrczak at knm.org.pl
 ^^ http://qrnik.knm.org.pl/~qrczak/


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /