in reply to Re^2: Static typing is mostly a waste of time
in thread Static typing is mostly a waste of time

Or unless you have a type "Non-negative number".
  • Comment on Re^3: Static typing is mostly a waste of time

Replies are listed 'Best First'.
Re^4: Static typing is mostly a waste of time
by iblech (Friar) on Apr 12, 2005 at 16:29 UTC
    Or unless you have a type "Non-negative number".

    Which you can define easily in Perl 6 :):

    my subtype NonNegativeNumber of Num where { not $^a < 0 }; my NonNegativeNumber $x = 3; # works my NonNegativeNumber $y = -3; # dies

    Another example of using subtypes:

    my subtype HTTP::Request::Method of Str where { $^method eq any <GET POST HEAD ...>; }; method send_using(HTTP::Request::Method $method) { ...; # Note: You don't have to manually check for $method # not being a valid HTTP method :). }

    --Ingo