On Fri, 3 Apr 2009, Moritz Lenz wrote:

Xiao Yafeng wrote:
1. Could I set multi-return type?like
                         sub test as (Int, Str) {...}

"as" is coercion - so to what would it coerce? Int or Str? How could the
compiler know? Or do you mean something like a tuple?

        I think he wants something like:

------------------------------------------------------------

sub example( -> Int, Str) {
        ...
        return(3, 4);
}

my($a, $b) = example();
$b.isa('Str') and say "b is a string"; # says "b is a string"

------------------------------------------------------------

...and hasn't learned the p6isms that express that. In other words, he wants to return multiple values, but enforce certain types on them.


---------------------------------------------------------------------
| Name: Tim Nelson                 | Because the Creator is,        |
| E-mail: wayl...@wayland.id.au    | I am                           |
---------------------------------------------------------------------

----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----

Reply via email to