[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Coding style



I wonder how people show in their code how a subroutine is altering a global variable.

Suppose that I have  in my main program a global var called @global and a function which is altering in someways this variable. I can write the call to this function in two ways to get the same result:

myFunc(\@global);

or 

@global = myFunc(\@global);

What the people consider the cleanest code. I'm always a little bit worried by what we call in French "effet de bord" (sorry can't find a translation), i.e. what the first part of this example is showing (altering a global without explicitly state it in the code).

My understanding at the moment is that when you pass by reference an array or a hash, there is nothing to show in the params that the  function have the right to make changes to the original.

In Ada, you can pass pointers to functions and procedure and specify (with "in", "in out") if the function is going to make alterations to the original. Is there something similar in Perl ?

Is this on topic for this mailing list ?

Cheers

-Emmanuel
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Emmanuel M. Dˇcarie - <emm@cam.org>
---> The Frontier Newbie Toolbox:
<http://www.cam.org/~emm/frontierNewbieToolbox.html>
---> Frontier en fran¨ais ! 
<http://www.scripting.com/frontier5/francais/>
<http://www.scriptmeridian.org/tutorials/francais/odb/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch