On Wed, Mar 09, 2005 at 02:15:56PM +0200, wolverian wrote:
: On Mon, Mar 07, 2005 at 08:40:19AM -0800, Larry Wall wrote:
: > Here are some alternatives you don't seem to have considered:
:
: [...]
:
: > my Str sub greeting (Str $person) is export {
: > "Hello, $person";
: > }
: >
: > my Str
: > sub greeting (Str $person) is export {
: > "Hello, $person";
: > }
:
: Do these declare the subroutine in the lexical scope only?
Yes, but if you're exporting the sub, references to it are potentially
escaping the lexical scope.
: > And I try to believe six foolish consistencies before breakfast each day.
:-)
:
: I'm glad you do! I value consistency a lot, but I do realise one has to
: choose the _right_ consistencies.
:
: Anyway, thanks for replying. I think I can live with the issue. :) It seems to
: center on the fact that Perl 6 allows you to put a lot of stuff into the
: signature. This isn't helped much by any potential Haskell-style pattern
: matching, at least not in a way I can see.
:
: I still do want to match against constants in the signature, however:
:
: sub foo ( 0 ) { ... }
: sub foo ( $bar ) { ... }
:
: So I'm very confused about my opinion on the issue of pattern matching..
Well that's just shorthand for:
sub foo ( Int $bar where { $_ == 0 } ) { ... }
sub foo ( $bar ) { ... }
except, of course, you'd have to mark them both as "multi" before you
get MMD. As it is, you'll get a warning about redefinition.
Larry