What perlop doesn't tell you about indirect method calls

B

Bo Lindbergh

hacker->${\sub{Perl->${\sub{another->${\sub{Just->${\sub{print"@_,"}}(@_)}}(@_)}}(@_)}}

.... and the hideous thing even runs under strict.


/Bo Lindbergh
 
U

Uri Guttman

hacker-> ${\sub{Perl->${\sub{another->${\sub{Just->${\sub{print"@_,"}}(@_)}}(@_)}}(@_)}}

those are direct method calls.

BL> ... and the hideous thing even runs under strict.

why shouldn't it? all those token are parsed as bareword class names
which is fine under strict.

uri
 
B

Bo Lindbergh

hacker-> ${\sub{Perl->${\sub{another->${\sub{Just->${\sub{print"@_,"}}(@_)}}(@_)}}(@_)}}

those are direct method calls.[/QUOTE]

Then what adjective should be used to distinguish between

$object -> method (@args)

and

$object -> $methodname (@args)

?


/Bo Lindbergh
 
U

Uri Guttman

[QUOTE="Uri Guttman said:
hacker-> ${\sub{Perl->${\sub{another->${\sub{Just->${\sub{print"@_,"}}(@_)}}(@_)}}(@_)}}

those are direct method calls.
[/QUOTE]

BL> Then what adjective should be used to distinguish between

BL> $object -> method (@args)

BL> and

BL> $object -> $methodname (@args)

dynamic method calls? delayed binding is another term used as the method
name is not known until the call is made. they are both direct since the
object (or classname) is unambiguous and uses -> to bind the method name
to the object/class. indirect calls are like:

new Classname @args
method $obj 'blah'

those are potentially buggy since a sub new() or method() could have
been declared earlier in the file and those would be called instead of a
method. this is documented in (i think) perlobj. that doc states that
you should never use indirect method calls. your code with a dynamic
method name is fine and i have used it in several places.

uri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top