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.
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:
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.
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:my $bork = Bork->new(); my $x = $bork->bork()->bork();
No ambiguity there. Either you get a 'Chef', or you get a compile-time error.Bork bork = new Bork(); Chef x = bork->bork()->bork();
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:
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.my Bork:$bork = Bork->new(); my Chef:$x = $bork->bork()->bork();
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Griping about Typing
by pdcawley (Hermit) on Apr 19, 2002 at 07:04 UTC | |
by tadman (Prior) on Apr 19, 2002 at 18:51 UTC | |
by pdcawley (Hermit) on Apr 22, 2002 at 15:52 UTC | |
by Anonymous Monk on Sep 29, 2003 at 23:39 UTC |
In Section
Meditations