in reply to RFC: Context tutorial

I was expecting more to be made of where contexts appear: particularly the fact that subroutine arguments are normally list context (you only mention this explicitly for print; the point could perhaps be generalised), and also -- without going into all the messy details of prototypes -- the fact that they sometimes unexpectedly aren't.

(I'm feeling particularly sensitive to that one because I was bitten by it the other day: took me a while to work out why

my @loc = ($offset, $length); my $part = substr $string, @loc;
was always just stripping the first two characters from my string...)

On re-reading, I see you may be touching on this in your preamble, but there you refer only to "operators", which I initially took as excluding functions like substr(). So maybe all that's needed is a little clarification up top.

Replies are listed 'Best First'.
Re^2: RFC: Context tutorial
by kyle (Abbot) on Jan 13, 2009 at 03:30 UTC

    I don't want to get into detailing what context is imposed by every Perl built-in, but I think you're right that I should mention that user-defined sub arguments are in list context. I'll put that in before I post it to Tutorials.