cpan you have to see
Guinevere Nell
guinevere.nell at gmail.com
Wed Dec 12 17:32:40 GMT 2012
I disagree - using $TRUE is fine! Perl was my first language and it makes
perfect sense to me.
More importantly: it seems the Perl community has lost it's warmth and
communal, welcoming, nature - maybe since it's a falling empire, people
have gotten rude and boorish? I don't know, but I am disappointed with the
way the list members are acting--I am not surprised that Perl is getting
few converts these days if this is how newcomers to the Perl community are
treated.
On Wed, Dec 12, 2012 at 5:23 PM, Edmund von der Burg
<evdb at ecclestoad.co.uk>wrote:
> On 12 December 2012 17:05, Alexej Magura <perlook at cpan.org> wrote:
> > Okay, allow me to clarify what the TrueFalse module that I wrote is
> trying
> > to emulate. It's trying to emulate the 'true' and 'false' user commands
> > available under Linux.
> >
> > Haven't you ever done something like this in Unix Shell?
> >
> > while true; do ls /var/log/; sleep 5s; clear; done
> >
> > The statment 'true' in this example, as far as I know, only returns true
> > and that's it. It may not look very useful, but it can be useful when
> > you just need to do something and just want to write 'Just because I
> > said so, keep doing A until I say stop.'
> >
> > I'm sorry if all of you think that my modules are poorly written, but if
> > you want me to take you seriously, then say something productive for a
> > change, that is make some suggestions (I'm open to suggestions.)
>
> Each language has its own idioms and ways to do things. In shell
> scripting the while true ... done loop is one of them.
>
> In Perl the equivalent would be while (1) { .... }
>
> I can understand that you want to make some of the Perl code you write
> more familiar by using constructs from other languages. However in
> this particular case you are making it more confusing for other
> developers. Your use of true or True means that they'll see something
> that reads well, but the exact behaviour of that code is not clear.
> However using something like '1' is unambiguous - 1 is almost always
> used when you need a true value.
>
> I'd suggest bringing across ideas from other languages, but using the
> language's own syntax to express them :)
>
> Cheers,
> Edmund.
>
>
> PS should 'True' not return 1 rather than 0?
> https://metacpan.org/source/PERLOOK/Ez-Tf-0.1.2.2/lib/Tf.pm#L74
>
> PPS if you do want to spell out true in your code you could add something
> like:
>
> use Readonly;
> Readonly my $TRUE => 1;
>
> ....
>
> while ( $TRUE ) {
> ....
> }
>
> # This will tell other developers that $TRUE is a variable (as it
> starts with a $) and lets them search for it in the same file that the
> use is in so they can see its value. It also can't be changed
> accidentally as it is readonly (https://metacpan.org/module/Readonly).
>
--
http://economicliberty.net/
More information about the london.pm
mailing list