On Thu, Aug 11, 2005 at 09:22:27AM -0700, Larry Wall wrote:
> On Thu, Aug 11, 2005 at 10:47:35AM +0800, Autrijus Tang wrote:
> : Adding inference ("is typed") to the mix massively sweetens the first
> : option, which would be a good thing.
>
> Only if the programmer can be taught to understand the inferences...
Aye. That is a very good argument for "is typed" to be off by default,
which I fully concur. :)
> Probably the first, actually, given the .= shortcut. It takes *me*
> a lot of thought to reproduce in my head what the inferencer is doing
> there, and you can't really understand code unless you can play the
> same mindgames the computer is playing. When the computer gets too
> smart, it forces anyone of less-than-genius caliber into cargo-cult
> programming. That's what I don't like about type inferencing systems.
Indeed, but I expect Perl6 programmers start rapid-prodotyping in the
dynamic variant of Perl6, so the inferencing does not kick in anyway.
However, once a programmer starts using type annotations, rapidly the
compiler will (rightfully) complain about unsafe coercing. That would
force the programmer into another kind of cargo-cult programming,
rampant in the Java world, namely manually key-in type declarations
everywhere.
Also, it is common in inference-based language environment to tell you
the inferred type for expressions, in a way that can be copy-and-pasted
back to the program, instead of having to type them out by hand.
Something like this:
pugs> sub fact ($x) is typed { [*] 1..$x }
pugs> :t &fact
sub fact (Int $x --> Int)
> And there's something to be said for locating type information near
> the "my" declaration for documentation purposes even if it's entirely
> redundant.
That is true.
> Actually, this is a case where a declared return variable would reduce
> my cognitive load since I don't have to scan for a return statement
> to see that $skip is in fact the return value:
>
> use traits 'typed';
> method skip (--> Test::Builder::Test::Skip $skip) {
> $skip .= new;
> my $status = $skip.status;
> $status.do_something; $skip.do_something; # ...
> }
>
> Arguably that's just locating the type near the "my" again, though the
> "my" is implicit in the signature in this case.
Yes, I think that form would rock. Also, I think leaving off the
Test::Builder::Test::Base::Status from the $status declaration does
not harm its documentation value -- indeed, that's the DWIM form Perl
programmers are used to.
Thanks,
/Autrijus/
pgpx3ztVyRQVk.pgp
Description: PGP signature
