develooper Front page | perl.perl6.language | Postings from April 2008

syntax question on parameter lists

Thread Next
From:
John M. Dlugosz
Date:
April 10, 2008 20:26
Subject:
syntax question on parameter lists
S06 shows how to define named-only parameters, "marked with a prefix :".  But no example shows anything more than a bare parameter name.  No type is ever given!

Looking through my copy of STD.pm, I'm baffled, as it seems not to take types in parameter lists at all.

So, is it
  method bytes ( Encoding :$encoding ) returns Int

or 

  method bytes ( : Encoding $encoding ) returns Int

?

I'm guessing that the latter would be confused with use of : after the invocant, and it follows that

  method bytes (Encoding :encoding($override_encoding)) returns Int

would work.

Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About