pass args by value or by ref but not both

Dumas Patrice <[email protected]> Tue, 14 Jan 2003 15:27:21 +0100
Newsgroups gmane.comp.tex.texi2html.devel
Message-ID <[email protected]>
Hi,

Some subroutines are evaluated for their side effects, with args passed by
address, like normalise_node, but somtimes the return value is used, too.
I think that the code would be more clear if there was only one way to
call the subroutine.

I also think that it should be better if it was made more clear whether
the args are passed by value or by adress. For example:

sub clean_name
{
    local ($_);
    $_ = &remove_style($_[0]);
    &unprotect_texi;
    return $_;
}

Here it is not so clear whther there are side effects or not, one has to
look at remove_style. If the function was written
sub clean_name
{
    local ($_);
    $_ = &remove_style(shift);
    &unprotect_texi;
    return $_;
}
things would be more clear. And giving formal names could even improve
readability :

sub clean_name
{
    local ($_);
    my $text = shift;
    $_ = &remove_style($text);
    &unprotect_texi;
    return $_;
}

In fact here this is not really needed but for other functions it could 
be nice.

Do you want to keep the code as it is or should I go on and modify that ?

Pat

Pat