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.

Again, though, assignment to a normal variable is unlikely to invoke
a constructor in any case.

Larry

Reply via email to