At 10:07 PM -0800 12/16/05, chromatic wrote:
On Friday 16 December 2005 18:15, Darren Duncan wrote:
 > 0. An undefined value should never magically change into a defined
 value, at least by default.

This is fairly well at odds with the principle that users shouldn't have to
bear the burden of static typing if they don't want it.

This matter is unrelated to static typing. The state of whether a variable is defined or not is orthoganal to its container type.

It sounds like you want to override the coercion of undef to fail, at least in
a lexical scope.  Go for it.

Yes.  Or have that be the default behaviour.

Just as having variables magically spring into existence on the first reference to them should not happen by default, and Perl 6 defaults to having this stricture turned on.

Likewise, it should have the stricture of no undef coersion on by default, but developers can turn it off locally as they turn off strict locally.

I can't see it as a default behavior though.  Sure, the literal expression "6
+ undef" is pretty silly, but I don't really want to write "6 + Maybe
$variable" (sorry, Haskellers) everywhere when the compiler is perfectly
capable of DWIMming in the 98% of cases where $variable is undefined because
I like being so lazy as not to initialize explicitly every possible variable
I could ever declare, being very careful to distinguish between 0, '', and
undef in boolean context.

I suspect the remaining two percent of cases, I won't write "6 + undef"

I think you're over-stating the frequency of situations where people actually want that auto-coersion; I'm thinking it is more like 50% at best.

But more to the point, if you assign your default values at strategic places, you are not writing very much extra code at all.

I find the argument against assigning explicit values to be only slightly stronger than the argument against using 'my' etc.

Those few characters are nothing considering the amount of hassle they can save.

-- Darren Duncan

Reply via email to