Just some thoughts (and an idea):
I have found the whole context thing in Perl5 easier to understand when I regard it as
overloading based on the return type. We all know that languages like C, C++ and Java
throw a compile-time error if two function
definitions differ in their return type only. Perl does something close to return type
overloading with many of its builtin functions. At least, that's the impression you
get from the outside (and I have never looked inside, so
excuse my lack of knowledge about the Perl5 internals ;-) )
Now my suggestion: Couldn't context sensivity in Perl6 be implemented by extending
multi-method dispatch to include return types? That could be generalized and would
allow things like:
my PNG $png = PNG.new("images/img0001.png");
my JPEG $jpeg = $png.convert();
my GIF $gif = $png.convert();
Of course you could have convertToJPEG() and convertToPNG(), but that's the whole
point of overloading and multimethod dispatch, isn't it?
The usual list context / scalar context distinction would of course still be possible.
It's just about _extending_ context sensivity.
[Comments | Suggestions | Criticism] welcome.