<table cellpadding=3 cellspacing=0 border=0 width=100% bgcolor=white><tr valign=top><td width=100%><font size=2 color=black>
<TABLE cellSpacing=0 cellPadding=3 width="100%" bgColor=white border=0>
<TBODY>
<TR vAlign=top>
<TD width="100%"><FONT color=black size=2>Guido wrote:<BR>&gt;Does Java have them?<BR> <BR>I know very little Java, but all the other object-oriented languages I use support in-out and out parameters. For example:<BR>C++:<BR>    void foo(int &amp;param) {param += 5;}<BR>    void bar(int &amp;param) {param = 10;}<BR>    // C++ does not distinguish between in-out and out parameters.<BR>    // call them<BR>    int x = 2; foo(x); // x is now 7<BR>    int y; bar(y); // y doesn't need to be initialized. It is now 10.<BR>    // Unfortunately, the C++ function definition doesn't indicate<BR>    // whether the argument needs to be initialized before the call.<BR>C#:<BR>    void foo(ref int param) {param += 5;} // passed value can be used<BR>    void bar(out int param) {param = 10;} // passed value cannot be used<BR>    // call them<BR>    int x = 2; foo(ref x); // x is now 7<BR>    int y; bar(out y); // y is now 10.<BR>Ada:<BR>    procedure foo(param : in out Integer) is begin param 
:= param + 5; end;<BR>    procedure bar(param : out Integer) is begin param := 10; end;<BR>    -- call them<BR>    Integer x := 2; foo(x); -- x is now 7<BR>    Integer y; bar(y); -- y is now 10<BR>Python:<BR>    def foo(paramWrapper):<BR>        paramWrapper[0] += 5<BR>    # Alternative:<BR>    def foo2(param):<BR>        return param + 5<BR>    def bar(paramWrapper):<BR>        paramWrapper[0] = 10<BR>    # call them<BR>    x = 2<BR>    wrapper = [x]<BR>    foo(wrapper)<BR>    x = wrapper[0] # x is now 7<BR>    # Three lines of it just to call foo in such a way that<BR>    # it can modify the value of the variable passed in.<BR>    # Alternative:<BR>    x = 2<BR>    x = foo2(x)<BR>    # Have to mention x twice just to let foo2 modify its value.<BR>    # Also, all the arguments to be modified get mixed in with<BR>    # the real function result if there is one.<BR>    wrapper = [None]<BR>    bar(wrapper)<BR>    y = wrapper[0] # y is now 10<BR>    # bar is not quite as big of a 
deal. The new value could<BR>    # have been returned as one of (possibly many) results.<BR>Proposed Python 3.0:<BR>    def foo(&amp;param):<BR>        param += 5<BR>    def bar(&amp;param):<BR>        param = 10<BR>    # call them<BR>    x = 2<BR>    foo(x) # x is now 7<BR>    y = None<BR>    bar(y) # y is now 10<BR> <BR>I have always considered this the most glaring omission in Python.<BR>If it will never happen, fine, it will always be a wart, but in-out<BR>and out parameters are common in object-oriented languages and make<BR>the code much more readable.<BR> <BR>Since we are considering optional type indications on parameters, I<BR>thought this would be a good time to explicitly allow a function to<BR>change the argument value by adding something to the parameter.<BR>It could look like foo(&amp;param) or foo(ref param) or foo(inout param)<BR>or foo(param:inout) or whatever. I don't really care.<BR>The code for both the function definition and the call would be 
clearer.<BR> <BR>#Rudy<BR><BR></FONT></TD></TR></TBODY></TABLE><br></font></td></tr></table><p><hr><font size=2 face=geneva><b>Join Excite! - <a href=http://www.excite.com target=_blank>http://www.excite.com</a></b><br>The most personalized portal on the Web!</font>