http://qs321.pair.com?node_id=160309


in reply to Griping about Typing

Typeless programming is great most of the time, but it can be a burning irritation as well. When the variables you are working with are malleable, like scalars, then you really don't care because of DWIM. When these scalars are actually object references, things can go all dark and blurry.
my $bork = Bork->new(); my $x = $bork->bork()->bork();
Quick quiz: What type of thing is $x anyway? What methods can you call on it? One of the great things about C++ and other strongly typed languages is that you have to prepare a holder for the thing you are requesting. It would be a lot more like:
Bork bork = new Bork(); Chef x = bork->bork()->bork();
No ambiguity there. Either you get a 'Chef', or you get a compile-time error.

With the coming Apocalypse, I only hope that there will be some sort of optional type checking mechanism that can backpropagate the request into the function itself, just like wantarray. Here's an idea:
my Bork:$bork = Bork->new(); my Chef:$x = $bork->bork()->bork();
Maybe the bork method would be able to return a number of different things, including a 'Chef', based on some sort of if (wanta('Chef')) { ... } type check.

Sure, you can say name your variables properly according to type, perhaps using the so-called Hungarian notation, but this can get quickly out of hand. You can also check the return types explicitly in some sort of paranoid gesture, but these are run-time errors and not compile time, which is really tough to test in comparison.

Strict type checking, please, but only on request.