Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^2: what would you like to see in perl5.12?

by moritz (Cardinal)
on Aug 19, 2007 at 19:54 UTC ( #633653=note: print w/ replies, xml ) Need Help??

in reply to Re: what would you like to see in perl5.12?
in thread what would you like to see in perl5.12?

The Perl 6 features I'd like to see most in 5.12 is optional static typing, and real subroutine/method prototypes, a la

sub repeat(Str $string, Int times)

That makes code very much self-documentatory, and perhaps the partial statitic typing allows for more optimizations.

Mind you, I have now idea if that's implementable with the current compiler/interpreter design - it's just a wish ;-)

Comment on Re^2: what would you like to see in perl5.12?
Download Code
Replies are listed 'Best First'.
Re^3: what would you like to see in perl5.12?
by EvanCarroll (Chaplain) on Aug 19, 2007 at 20:05 UTC
    Bump the Moose suggestion and you can get close to that functionality now...
    use Moose; has 'string' => ( isa => 'Str', is => 'rw' ); has 'times' => ( isa => 'Int', is => 'rw' ); sub foo { my $self = shift; my ( $string, $times ) = ( $self->string, $self->times ); }

    Evan Carroll
      Would that work with sub signatures (not methods), and does it allow for the same kind of optimization that is possible if the compiler knows about the types?
Re^3: what would you like to see in perl5.12?
by Jenda (Abbot) on Aug 20, 2007 at 12:36 UTC

    Why would anyone want to repeat the failed experiment of prefix types?  sub foo( Str $ref->[]{}, Int @arr[], Str $fun(Int bogus, Real otherbogus)) anyone?

      What makes you think that prefix types are a "failed experiment"?

      If you are talking about prototypes, that's hardly the same.

      Many staticly typed languages use it successfully, and if it stays optional I don't see a point against it.

      If you don't like the notation, you are of course free to omit the types - that's why I wrote optional static typing.

      BTW. I guess it would be Int @arr instead of Int @arr[].

      (Update: fixed thinko spotted by holli)

        Some programming languages use it with mixed success. With success for the simple cases of int and char variables, and utter failure for the more complex cases of (horrors) pointers to functions returning pointers or functions receiving pointers to functions. char *(*)foo(...)? Feeling well?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://633653]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2015-10-08 18:35 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (222 votes), past polls