Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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
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
    www.EvanCarroll.com
      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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-04-20 22:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls