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

Re: Prototypes

Thread Previous | Thread Next
From:
Ken Fox
Date:
September 3, 2001 20:39
Subject:
Re: Prototypes
Message ID:
3B944EE2.12AD3F72@vulpes.com
"Bryan C. Warnock" wrote:
> {
>     my $a = sub ($$) { code };
>     gork($a);
> }
> 
> sub gork {
>     my ($a) = shift;
>     $a->(@some_list);  # <- Here
> }
> 
> The reason prototypes aren't checked at "Here" is because there really
> isn't a way to know what the prototype was.

Um, that's not true. ML can do stuff like that -- all automatically and
without any type declarations.

What happens is the type of gork's $a is determined, which cascades
to the type of gork's $_[0], which cascade's to your first block's $a.
ML even has polymorphic functions where the output type depends on the
input type.

It is possible. It's just a question of whether we want to do it.

- 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