in reply to Re^5: Calling module function from within a blessed module
in thread Calling module function from within a blessed module
The general idea I trying to get across — and, perhaps, didn't explain sufficiently well — was that problems are less likely to occur from a hard-coded package name, but rather from accidentally using an incorrect variable; the likelihood of which is exacerbated by poorly chosen (especially single-letter) variable names.
The type of scenario I envisaged, involved $x being used for some purpose, and ultimately ending up with a value of zero. Later in the code, a variable to represent either an X class, or an object thereof, was wanted. As $x was already taken, the coder chose the next available, single-letter variable, $y.
Subsequently, and paraphasing your example, the intuitive but incorrect @{"${x}::ISA"} and bless {}, $x was used; when, of course, the unintuitive yet correct @{"${y}::ISA"} and bless {}, $y was needed.
Possibly getting a little off-topic (and hopefully not heading towards too much of a rant) but, in the main, meaningful names should be used, and single-letter names should be generally avoided. There are a few well-known examples where single-letter names are fine; e.g. sort { $a <=> $b } and in the limited scope of for my $i (0..$#ary). I also use them in one-liners and short example code. Other than that, I always aim to use meaningful names.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Calling module function from within a blessed module
by haukex (Archbishop) on Jan 03, 2021 at 10:34 UTC | |
by kcott (Archbishop) on Jan 03, 2021 at 21:18 UTC |