Front page | perl.perl6.language |
Postings from May 2005
Re: s/true/better name/
Thread Previous
|
Thread Next
From:
Thomas.Sandlass
Date:
May 24, 2005 09:11
Subject:
Re: s/true/better name/
Message ID:
4293521E.2040709@orthogon.com
Sorry, that I excavate that thread, but it just fits my question.
Rod Adams wrote:
> Well, "and" and "or" serve the purpose of being at a much lower
> precedence level than "&&" and "||".
>
> I would see the value in alphabetic "not" as serving the same relation
> to "!". But I would still see it returning a Bool, not a numified 0 or
> 1. I could see a "boolean" operator serving the same relation to "?".
The question is: are ?, !, not and true returning values besides the
boolean evaluation? Something like 'value but true'? To wit:
my $a = 4;
my $b = 0;
say 'true' if $a; # prints 'true'
say $a && $b; # prints '4'
say ($a and $b); # same, parens needed for precedence
say 'true' if not $b; # prints 'true'
say not $a; # prints 0, or '4 but false'
say $b || not $a; # prints '4 but false'
say $b || !$a; # prints '4 but false'
say bit $a; # prints '0' or 'false'
say bool $a; # print '4 but true'
> But for those cases where someone absolutely has to have a 1 or 0, not
> some Boolean object, sticking a "+" or "int" in front of a "!", "?",
> "not", or "boolean" seems to cover that case fine.
Boolean return values are the task of unary ?^, aren't they? Continuing
from above +?$a would still be 4 not bit::true, right? Even ~+?*+?$a is
as far as the value is concerned a no-op? Thus to really flatten away the
value one needs to use ?^ which has bit as the alpha pendant?
If my above assumptions are correct I would like to get bool as the
alpha pendant to ? like not for !. BTW are num and str the equivalents
of + and ~ respectively? And - has no corresponding neg or so? The strings
'true' and 'false' should really be kept as enums of the bit type.
Thanks for your patience with me.
--
TSa (Thomas Sandlaß)
Thread Previous
|
Thread Next