[Phoenix-pm] Tricksy! False!

Mike Friedman frimicc at gmail.com
Sun Nov 8 00:35:40 PST 2015


Oh, I can see lots of uses for it. Making objects act as True or False, depending on their contents comes most strongly to mind. "if ($thing_in_db) { # thing is in db } else { # thing is not in db }"

But mostly I think two things from this syntax:
1. How the heck are you going to grep your code usefully for "but"?
2. Making things True or False by programmer fiat is going to cause a whole pile of hard-to-debug errors unless it's backed up by coding standards enforced with a BIG stick. 

In any event, I wish I could've gone to the presentation. I haven't had any time to play with Perl 6 yet, but it looks like it's going to be an interesting playground.

-- Mike
______________________________
Michael Friedman
frimicc at gmail.com

> On Nov 7, 2015, at 11:34 PM, Douglas E. Miles <doug at veritablesoftware.com> wrote:
> 
> Since you weren't at the presentation, the real case for this feature was for things like the system function, where it returns 0 on success, so you can do things like:
> 
> my $foo = 0 but True;
> 
> The equivalent in Perl 5 was 0e0. Anyway, it was just something I had read about but hadn't tried, and as I noted, "This is evil". :)
> 
> P.S. Good to hear from you!
> 
>> On 11/7/2015 10:15 PM, Mike Friedman wrote:
>> Some language features really should never be used. NEVER. 
>> 
>> -- Mike
>> ______________________________
>> Michael Friedman
>> frimicc at gmail.com
>> 
>> On Nov 7, 2015, at 2:59 PM, Douglas E. Miles <doug at veritablesoftware.com>         wrote:
>> 
>>> I had to try this one for myself just to make sure it actually worked.
>>> 
>>> liar.p6:
>>> #!/usr/bin/env perl6
>>> 
>>> use v6;
>>> 
>>> my $foo = True but False;
>>> say $foo;
>>> Output:
>>> $ ./liar.p6
>>> False
>>> 
>>> Note that this is only true (but False) for the value of $foo. It does not re-define True as False globally.
>>> 
>>> P.S. This is evil. :)
>>> _______________________________________________
>>> Phoenix-pm mailing list
>>> Phoenix-pm at pm.org
>>> http://mail.pm.org/mailman/listinfo/phoenix-pm
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/phoenix-pm/attachments/20151108/bfbfc0a9/attachment-0001.html>


More information about the Phoenix-pm mailing list