On Thu, Jun 24, 2004 at 08:44:45PM +0200, Juerd wrote:
: Larry Wall skribis 2004-06-24 11:29 (-0700):
: > This is Perl 6.  Everything is an object, or at least pretends to be one.
: > Everything has a .boolean method that returns 0 or 1.  All conditionals
: > call the .boolean method, at least in the abstract.  (The optimizer is
: > free to optimize the method call away for known types within known
: > conditionals, of course.  It had better, or evaluating the truth of
: > .boolean will end up calling .boolean again...  :-)
: 
: I didn't know about the (to-be) existence of .boolean. It makes things
: fun and easy, though.
: 
: However, is the name "boolean" final? I would prefer "true", perhaps
: with a corresponding "false". 

Well, the type/property name doesn't have to be "boolean"--it could
be "truth", instead.  But we mustn't confuse the type (false, true)
with either true or false.  In general, the name of a property is a
type, so the truth property is something like "boolean" or "truth",
with an underlying base type of "bit".  According to A12, you can
use a value of an enumerated type as a shorthand, so if you say

    $x.true

it's short for something like

    $x.boolean == boolean::true

And when you say

    0 but true

a whole bunch of magic happens that creates a type with a .boolean method
that returns the value true.

: That is, assuming that there will be $foo.defined and $foo.empty. Hm. I
: wonder where (and if) I read about .empty. Can't find it.

I'm afraid .empty was just a p6l speculation.  But .defined is a real
property/method.

: > not when the data becomes false.  Plus we'll have the // operator.)
: 
: I'll be wanting a length-or. Perl 6 will make coding it easy enough to
: not need it in the core.

What do you mean by "length"?  Length is not a generic concept in Perl
6, and there is no .length method.  You'll have to be more specific
about what *kind* of length you're talking about: byte length,
codepoint length, grapheme length, element length, etc.

However, for most types possessing one or more kinds of length, it
works out that the boolean value will be true if there is any length
and false otherwise.  (Untyped scalars still have the caveat about
string "0" though.)  So you don't need a length-or at all.  (Or if you
do, you need it less than Perl 5 did, and we've gotten by without it
for quite a while now there.)

: But the operator needs a symbol. I'm assuming
: infix:"" will work. But will there be a way to ask Perl if syntax can be
: used without introducing possible ambiguity?

Good question.  I expect we can manage to give an optional warning if
one operator completely hides another.  On the other hand, it might be
intentional.  (However, infix:"" wouldn't necessarily hide anything,
since it would only be looked for where an operator is expected.
prefix:"" is another matter...  But it's probably a bad idea anyway
since you'd screw up the lookahead that determines whether you can
drop the parens on a method call.)

: A circumfix ++ operator won't work for several reasons. What will Perl
: do if you try defining one?

Probably depends on whether Perl decides the initial circumfix + is
indistinguishable from a unary +.  While it's theoretically possible
to attempt to parse as circumfix and then backtrack to prefix if that
doesn't work, it's probably a bad plan from a human understandability
point of view.  Backtracking is a wonderful concept till you have to
do it.

On the other hand, if you declare your circumfix:++ with "is forced"
or some such, then maybe it just hides prefix:+ without a warning.

: Please don't say that picking a random sequence of at least 5 different
: unicode dingbats will be the best way to be sure :)

Oh, I'd never say that.  The Perl Way is that the computer always
tries insanely hard to serve your needs.  In Soviet Russia (and
similar places) the computer is served by you.

However, visual distinctions might well be the best way to keep the
*human* reader clued to his terminal, so you might want to keep those
five random dingbats close to hand...

Larry

Reply via email to