First, it's both immoral and illogical to claim to be sorry for actions you believe to be right or correct. Typing in the claim you are sorry, meaning you don't think you should have done it, right before doing it, is rather insulting. Perhaps because you are saying sorry for what you're doing, instead saying you're sorry if it bothers anyone. The meanings are very different.
Second, yes there is a difference if you have prototypes. But, you don't (or shouldn't) if you're asking this sort of question. It would have been good to show bug free examples where correct behavior is different, instead of just showing you can make them error differently. Unless you just meant they can error differently, but no you must have had a deeper understanding to have constructed them.
& is dereferenced only at runtime, and function prototypes are checked at compile time. Of course, in your example the use of prototypes is the only bug, though you did manage to get them to error out differently; two with logic errors and the other with a compile error.
it should be noted that it is very rare where use of prototypes isn't a bug (born usually of the unfortunate label "prototypes" and the confusion with C prototypes).
Here is one example where they are different and also work:
So with the prototype working, $_[0] gets a ref to an alias of @array, whereas without the prototype, $_[0] just gets an alias to $array[0].@array = ( "one","two" ); foo( @array ); &foo( @array ); sub foo (\@@) { print "arg one is a ", ref $_[0] || "non-ref with value $_[0]" +; } __END__ output: arg one is a ARRAY arg one is a non-ref with value one
But for the record I still say, newbies should be told they are the same. Maybe with a disclaimer about, "unless you're using prototypes" and then let them learn that when the time comes.
In reply to Re^4: To & or not to & ?
by Aighearach
in thread To & or not to & ?
by DrWhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |