On Mon, 3 Feb 2003, Deborah Ariel Pickett wrote:

> I guess what I'm saying is that someone needs to provide a real-world,
> non-contrived, example showing ??= in use.

Fair enough.  Real World, Non-Contrived: In all databases that I've ever
worked with there are exactly two possible values for a boolean database
field.  Those two values are usually 't' and 'f', though in my designs I
prefer to use '1' and '0', to keep things more perlish.

Now, when a value comes in from a web page, it might be anything.  In
particular a checkbox is going to be either undef (if the checkbox wasn't
checked, the standard is that the field isn't sent at all) or whatever the
<INPUT> tag's VALUE attribute is set to, or 'on' (if VALUE isn't set).
There is simply no way to directly get 'f' or 0 from the HTTP request, and
't' requires extra work.  Ergo, it's necessary to massage the data a
little to fit it into 't' and 'f'.

In short, although Perl is quite robust about what's "true" and "false",
other computer systems are more fussy.  I personally find myself
explicitly setting variables to 1 or 0 quite frequently, and I always use
?:.  It would be a nice little shorthand addition to have ??= in Perl6.

Obviously this isn't a major requirement.  It's just a nice little
shortcut that would clean the code in the same way the other shortcuts do.
I always feel somehow redundant type C<$var = $var ? 1 : 0>, and ??= would
just be nice and tidy.

-miko


Miko O'Sullivan
Programmer Analyst
Rescue Mission of Roanoke

Reply via email to