User: Password:
|
|
Subscribe / Log in / New account

Affects Perl too

Affects Perl too

Posted Mar 12, 2014 22:34 UTC (Wed) by gerdesj (subscriber, #5446)
In reply to: Affects Perl too by dskoll
Parent article: A false midnight

You and me both. I am not a particularly skilled programmer but I have to write scripts from time to time in quite a few languages.

To avoid corner cases like that or effects that are well known to "experts" but not me I always spell out tests as simply and unambiguously as possible with the emphasis on unambiguously. I can generate bugs at quite a rate myself without trying to be clever.

Now, times are especially weird as a data type due to the myriad rules and the modulo effect and to even contemplate trying to squeeze in a notion of one time being true whilst another false looks bloody stupid to me.

It looks to me like the clever buggers who test the existence of a var with if $var are just plain lazy. If it's a common construct then I think it's probably a really stupid one. I think that you are effectively wanting to test a variable's existence by comparing its value with true/false which are two different things.

Surely you should test for "is not null" (or whatever syntax is necessary in the language concerned) which implies existence or test the contents of the variable. Trying to do both at once clearly ends in tears eventually or ends up with strange discussions about date/times that might be true or false

Cheers
Jon


(Log in to post comments)

Affects Perl too

Posted Mar 12, 2014 23:06 UTC (Wed) by dchichkov (guest, #90878) [Link]

I would kindly suggest writing readable code and emphasizing readability.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds