in reply to Re: Re: Using "my" suppresses "Name used only once" warning?
in thread Using "my" suppresses "Name used only once" warning?
I guess what I'm really after is a psuedo strong type casting option for variables. In other words, if I used a scalar in string context, I want to be warned if I later use it as a number (even if it looks like a number).
Then you shouldn't have used Perl to begin with. This automatic casting between numbers and strings is a feature, just as it's considered a feature in C that if you divide a float by an integer, the integer is casted to a float.
Also realize that in Perl, that any checking of the form "is this a number" has to be done at run-time (unlike the typechecking in C that can be done in compile time). You really don't want to do a check for each operation, the slowdown would be noticeable. You get the "Argument 'foo' isn't numeric" for 'free', because Perl needs to convert the string value to a numeric value, and the C library functions strto* will flag failure. You will notice that you get the warning only if Perl hasn't attempted to translate the string value to a numeric value - if Perl already did this (unsuccesfully), you don't get a warning.
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Using "my" suppresses "Name used only once" warning?
by Wysardry (Pilgrim) on Feb 03, 2003 at 02:14 UTC | |
by Abigail-II (Bishop) on Feb 03, 2003 at 08:18 UTC | |
by Wysardry (Pilgrim) on Feb 03, 2003 at 18:53 UTC | |
by Abigail-II (Bishop) on Feb 03, 2003 at 23:05 UTC | |
by Wysardry (Pilgrim) on Feb 04, 2003 at 00:01 UTC | |
by Biker (Priest) on Feb 03, 2003 at 13:17 UTC |