Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Re: Re: style q: duplication? of variables

by bikeNomad (Priest)
on Aug 14, 2001 at 19:10 UTC ( #104790=note: print w/replies, xml ) Need Help??

in reply to Re: Re: style q: duplication? of variables
in thread style q: duplication? of variables

I definitely don't like it when in a language I can't see at the function call whether an argument might be changed.

Well, you picked a trivial example (scalars, specifically strings). In much of the Perl code you'll see, references are being passed around anyway, since plain old scalars have limited usefulness.

What you may want to do is to adopt a naming convention to signify subroutines that take scalar arguments and modify them.

You note that this was a disadvantage of Ruby; but note that Ruby has a convention of using a trailing '!' sign to denote methods that modify value types (especially) in place (i.e. chomp!() vs. chomp()). Maybe your Perl code could do something similar (i.e. truncate() vs. truncated(), perhaps).

  • Comment on Re: Re: Re: style q: duplication? of variables

Replies are listed 'Best First'.
Re: Re: Re: Re: style q: duplication? of variables
by stefan k (Curate) on Aug 14, 2001 at 19:46 UTC
    Thank you both for cheering me up. Actually it wasn't that bad anyway. :-)

    As for the ruby part: They constantly claim to be so very clean in design and everything (which perl doesn't :) and then such things annoy me. If a language was very good designed it should not allow the changing of a passed parameter without the caller explicitly allowing it IMHO, but that's probably just a matter of taste. Using just a convention is not good design because it can be avoided.
    In my early C-days I "invented" a convention for myself which pretty much was OO design (without knowing anything about OO) and one would hardly find a compiler whichs tells me when I'm wrong with my own conventions *grin*

    Since I (almost) always use the my ($val1,$val2) = @_;-way of passing args I'm not feeling endangered here.

    Anyway, I like coding in perl most of the time (until it gets to complex datastructures), I kinda enjoy coding in ruby, too (which I do for just two weeks now) and so I'll switch desktops soon...

    Regards... Stefan

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://104790]
[karlgoethebier]: sometimes rereading manages is helpful ;-) at least for me...
[Eily]: hello people \o/
[karlgoethebier]: manpages..
[Eily]: and non-people and NodeReaper
[Discipulus]: you so kid to greet non people..;=)
Discipulus kind not kid..
[Corion]: The bots bow in response
[Discipulus]: so karlgoethebier, what this idiom is and where i can read about it? i tried to deparse and gives error..;=(
[karlgoethebier]: Eily: non-people == persone non grata?

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-07-21 08:05 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (319 votes). Check out past polls.