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

Re: Quick question on subroutine declaration syntax

Thread Previous
From:
Aaron Sherman
Date:
October 30, 2001 07:04
Subject:
Re: Quick question on subroutine declaration syntax
Message ID:
20011030100431.C25653@ajs.com
On Tue, Oct 30, 2001 at 03:59:30PM +1100, Damian Conway wrote:

> (Though I *do* harbour a secret desire to resurrect -> as a type specifier:
> 
> 	sub foo (@args) -> rettype

Hmm... I would have expected "is" to come in here:

	sub foo (@args) is IO::Handle

> 	my $bar -> int;

Hmm... This, I think is very different. Now you're getting into
casting, and I fear a Perl6 that has casting. Next, we'll have to
start considering the various types of casting that C++ provides
(static, dynamic, etc).

Did you think of -> as forcing the "my" expression to return a certain
type or to say that $bar is of type int or to say that $bar is whatever
it is, but will always be forced into an int when its value is taken
(much like the behavior of Perl6 hash keys)?

I could see each of those being useful, but I'm not sure they are
all neccessary.

-- 
Aaron Sherman
ajs@ajs.com		finger ajskey@b5.ajs.com for GPG info. Fingerprint:
www.ajs.com/~ajs	6DC1 F67A B9FB 2FBA D04C  619E FC35 5713 2676 CEAF
  "Write your letters in the sand for the day I'll take your hand
   In the land that our grandchildren knew." -Queen/_'39_

Thread Previous


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