in reply to Re^10: why doesn't "my ($a,$b)" return a list?
in thread why doesn't "my ($a,$b)" return a list?
Funny you should pick grep as your example of a function because there is no grep function anywhere. It's gets compiled into the grepstart and grepwhile opcodes. You'll find that none of the named operators are compiled into function calls. They are typically compiled into opcodes which the same name as the function or operator.
$ perl -MO=Concise,-exec -e'time();' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <0> time[t1] v 4 <@> leave[1 ref] vKP/REFC -e syntax OK
As a function call, it would look like:
$ perl -MO=Concise,-exec -e'timex();' 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <0> pushmark s 4 <$> gv(*timex) s/EARLYCV 5 <1> entersub[t1] vKS/TARG,1 6 <@> leave[1 ref] vKP/REFC -e syntax OK
The point is that there's really no difference between grep, eq and the rest of perlfunc and perlop except for perceived differences. There's a set you perceive as functions, and that's exactly what I said earlier.
maybe "my" is something else, for me it belongs in the same class as "sub",
Well, I was saying that when my looks like a function, you shouldn't be surprised that my acts like a function. sub doesn't really look like a function.
I don't know what this class is you are defining, nor how it relates to this conversation.
Keyword?
Yes, "my" is a keyword. It's quite a vague description, though.
perlsyn uses the term "statement".
While my $x would be a statement, my is not a statement itself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^12: why doesn't "my ($a,$b)" return a list?
by LanX (Saint) on Aug 19, 2010 at 23:34 UTC | |
by ikegami (Patriarch) on Aug 19, 2010 at 23:37 UTC | |
by LanX (Saint) on Aug 20, 2010 at 21:33 UTC |