develooper Front page | perl.perl6.language | Postings from September 2001

Re: Will subroutine signatures apply to methods in Perl6

Thread Previous | Thread Next
From:
Ken Fox
Date:
September 1, 2001 10:40
Subject:
Re: Will subroutine signatures apply to methods in Perl6
Message ID:
3B911F9D.C8A9EDB1@vulpes.com
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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About