Uri Guttman wrote:
[Re: use strict 'typing'; my $rex = new Dog; $rex.bark]
> then it should be a compile time error at the assignment to $rex
> and not later. you can't trace $rex at compile time to see what
> kind of object (if any) was assigned to it. so the illegal method
> call can't (easily) be detected at compile time. it has to be a
> runtime error.

I agree with this comment, but I think the approach has serious
usability problems. From my experience with using "const" in C++,
it looks like this pragma will be *very* difficult to use.
Perl code also tends to be highly generic and polymorphic.

Wouldn't it be better to handle strict typing as a warning in
the places where the type information isn't known? In the Dog
example, "my $rex = new Dog" would generate a warning, unless
Dog::new was typed.

Also, I think it would be excellent to have an "assumptions"
pragma to complement strict typing. If the Dog package does not
declare type information, I could write an assumption to quiet
the strict type warnings. If the assumption is false (maybe
the author of Dog adds type declarations someday), then an
"invalid assumption" error should occur at compile time.

- Ken

Reply via email to