At 5:19 PM -0700 8/28/02, Larry Wall wrote:
>On Thu, 29 Aug 2002, Steffen Mueller wrote:
>: Nicholas Clark wrote:
>: [...]
>: > If the compiler were able to see that my Date $bday = 'June 25, 2002';
>: > is one statement that both types $bday as Date, and then assigns a
>: > constant to it, is it possible to do the conversion of that constant
>: > to a constant $bday object at compile time? (and hence get compile
>: > time checking) Without affecting general run time behaviour.
>:
>: While that may be possible (I can't tell, I gladly take Dan's word for it),
>: it doesn't make much sense IMHO. It means that you can only initialize those
>: objects with constants. That's not a problem for people who know Perl well,
>: but it is going to be one hell of a confusion for anybody learning Perl. I
>: can see people whining on clpm why they can't do "my Dog $rex =
>: sub_returning_string();". Again IMHO, taking Perl's flexibility in *some*
>: cases is much worse than making it Java.
>
>We're not going to define it so they can only initialize with constants.
>That would be silly.  I think Dan is talking about the case where we
>can detect that it is a constant at compile time.  As such, it's just
>constant folding, on the assumption that we also know the constructor
>isn't going to change.

I actually had something a bit more subversive in mind, where the 
assignment operator for the Date class did some magic the same way we 
do now when we do math on strings.

On second thought, that's not a great idea, and I think just passing 
in parameters to the class' initialization method's a better idea, 
otherwise we'll have string auto-converting going on all over the 
place, and that's not a great idea.

-- 
                                         Dan

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

Reply via email to