At 8:11 PM -0400 5/23/02, Miko O'Sullivan wrote:
>From: "Chris Angell" <[EMAIL PROTECTED]>
>>  I have an idea for the int() function.  I think it would be cool if it
>>  returned false/undefined when the argument passed to it is a
>>  whole number.
>
>This is related to something I've been pondering about variables and typing.
>
>Question A: In Perl6, how are types enforced?  What would be the result
>of trying to compile and run the following code:
>
>   my int $foo;
>  $foo = 'Fred';
>
>The rest of this message assumes that the answer to A is "run time error".

I'm not sure that's correct. Might just be a runtime warning, with 
$foo set to 0. Or a compile time error or warning, as we do know at 
compile time what the behaviour of the int class is, and would likely 
do this with some constant twiddling during the compile phase.

Dynamic assignment, like:

     $foo = $bar;

would likely throw an exception at runtime, since the type mismatch 
can't be safely inferred at compile time.
-- 
                                         Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                       teddy bears get drunk

Reply via email to