Get the reference to an array from a function...

D

David Squire

Sherm said:
It does - have a look at "perldoc -f wantarray".

Yes. If I had thought longer, I would have remembered wantarray. I guess
it is just a bit of implicit polymorphism in how the argument to return
is handled when putting stuff on the stack.

Regards,

DS
 
S

Stephan Titard

David Squire escribió:
True, and, to me, surprising. This implies that the subroutine knows the
context in which it was called, which seems to me to break all sorts of
principals of encapsulation, low coupling, etc.


DS
but it is *not* actually, context is forced on the subroutine (it
propagates down the call chain if you are not playing tricks -- magic
goto, etc...), and the only thing the sub can do is decide what to do
according to context...
it is good practice to design your sub the have a sensible return
according to context

Also, Contextual::Return is worth a look.
hth
--stephan
 

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

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top