RE: Some questions about operators.

2004-03-20 Thread Austin Hastings


 -Original Message-
 From: Luke Palmer [mailto:[EMAIL PROTECTED]
 Austin Hastings writes:
   From: Luke Palmer [mailto:[EMAIL PROTECTED]
   Joe Gottman writes:
2) Do all of the xor variants have the property that
chained calls return true if exactly one input
parameter is true?
   
   I would imagine not.  Cxor is spelled out, and by
   definition XOR returns parity.  On the other hand,
   the junctive ^ (one()) is exactly one.
  
  Hmmm: If infix:xor returns Scalar.boolean, there might be hope. This
  would involve returning something like a.or.b but a.xor.b.
 
 I don't know what you're hoping for when you say 'hope.'

Let's look at boolean xor:

  if ($a xor $b xor $c) {...}

should succeed only when exactly one of ($a, $b, $c) is true. This corresponds roughly 
to constructing and then collapsing a one() junction:

  if one (?$a, ?$b, ?$c) {...}

If XOR is true, it should return 1/true. If XOR is false, it can either be false, but 
not preclusive of later success, or definitely false. (Remember a year ago when we 
talked about how many values should be present in a logical type?)

So definitely false xor anything is false.

But tentatively false is 0/false. It passes into another XOR just fine.

Thus:

   tentatively false = 0
   definitely false  = 1/false. (or perhaps false/1 ?)

So

sub infix:xor(Scalar $a, Scalar $b) {
  my $left  = (?$a == ?($a.value)) ?? ?$a :: 1; # 0/true  is true,
  my $right = (?$b == ?($b.value)) ?? ?$b :: 1; # 1/false is 1

  if ($left  $right) { return 1 but false; }
  if ($left || $right) { return 1; }
  else   return 0;
}

means that:

  0 xor 0 == 0
  0 xor 1 == 1
  1 xor 0 == 1
  1 xor 1 == 1/false (!!)

so that:

  (1 xor 1) xor 0 == 0
  (1 xor 1) xor 1 == 1/false

Ad infinitum.


3) Is there an ASCII digraph for the | operator?
   No. Just use Czip. 
  
  Re: | vs 
  
  Boggle! Who let that slip in?
  
  I kind of got the impression he was asking about e.g., ??! or some
  such, a la ANSI C. (In the same vein as  for , etc.)
  
  But no, it's far worse: every keyboard that is capable of generating
  '|' is labeled incorrectly. How's that for the principle of least
  surprise?
 
 I've never been too fond of the (lack of) visual distinction between |
 and  .  They're just too similar.  I'd much rather see something like
 U+299A VERTICAL ZIGZAG LINE ().  But alas, not in latin-1 (not to
 mention my terminal's inability to render that character, but that
 wasn't a design constraint last time I checked -).
 
 But context serves us humans well here.  Very infrequently will you see:
 
 for @a | @b - $a, $b {...}
 
 My head hurts just thinking about what that actually does.  Among other
 things, it should probably issue a warning saying did you mean  ?

Granted. But some pitaph is going to come along and find a novel new use for zip 
outside of loops. And then it's going to be in an expression of some kind, where the 
parser won't know what to do...

Ah, well, that's what P6tidy will be for. That program's going to have a hella-long 
configuration setup...


  PS:
  
  S3 appears inconsistent WRT the . operator and hyperoperation. One
  example uses (f,oo,bar).length, while elsewhere you have
  @objects.run();
 
 Oops.  The latter is correct.

I saw something a while back from $Larry talking about some consensus leaning towards 
always being balanced. Is that a misrecollection on my part, or was there some 
counterexample which actually provides value for  xor  xor  ?

=Austin



Re: Some questions about operators.

2004-03-20 Thread Damian Conway
Austin Hastings wrote:

Granted. But some pitaph is going to come along and find a novel new use for 
 zip outside of loops. And then it's going to be in an expression of some kind,
where the parser won't know what to do...
	%hash = @keys  @values;

Oh, and it's petaQ  not pitaph.

Hey...wait a minute!

tlhInganHol
petaQ chopong?
bIQambogh DaqDaq qaHoH!!
/tlhInganHol
{{;-)

Damian


Re: Some questions about operators.

2004-03-20 Thread Simon Cozens
[EMAIL PROTECTED] (Austin Hastings) writes:
  I'm not sure that having quaternary logic in Perl 6 is necessarily a good
  idea. Why stop only at four states?
 
 Total about twelve possible states plus junctions, of which eight or nine
 would be 'useful', and only three would be knowingly used.

Irony is wasted on perl6-language.

-- 
A year spent in artificial intelligence is enough to make one believe in God.


RE: Some questions about operators.

2004-03-20 Thread Austin Hastings


 -Original Message-
 From: Damian Conway [mailto:[EMAIL PROTECTED]
 
 Austin Hastings wrote:
 
  Granted. But some pitaph is going to come along and find a 
  novel new use for zip outside of loops. And then it's going
  to be in an  expression of some kind, where the parser won't
  know what to do...
 
   %hash = @keys  @values;
 
 Oh, and it's petaQ  not pitaph.

Umm, no. It's pitaph, vice japh. (Better than gdtsfhogwaph, certainly.)

But you make my point.

BTW, how did you generate that , or did you mouse it?

=Austin




broken bar (Re: Some questions about operators.)

2004-03-20 Thread Karl Brodowsky
Dear All,

I think that the broken bar is dangerous.  Why:
It can be mixed up with the normal bar |.  In some fonts it looks the same.
And to many people it is not 100% clear, which of the two bars is the broken
one and which not.
Off course it is possible to avoid this, but that is not solving the problem
of reading perl-code that someone else has written.  The «» are not such a problem.
But I would think that it would still be worth considering to avoid the broken bar.
Sorry if this disscussion has been performend 1000 times already.

Best regards,

Karl



Re: Some questions about operators.

2004-03-20 Thread Dan Sugalski
At 9:19 PM + 3/20/04, Simon Cozens wrote:
[EMAIL PROTECTED] (Austin Hastings) writes:
  I'm not sure that having quaternary logic in Perl 6 is necessarily a good
  idea. Why stop only at four states?
 Total about twelve possible states plus junctions, of which eight or nine
 would be 'useful', and only three would be knowingly used.
Irony is wasted on perl6-language.
And this is a new revelation?
--
Dan
--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


Re: broken bar (Re: Some questions about operators.)

2004-03-20 Thread Larry Wall
Well, maybe we should use yen (¥) instead.  It even looks like a zipper.

(Of course, we'll leave out the little problem that half the people
in Japan would read it as a backslash wannabe...that's not really
a problem since a zipper would only be used where an operator is
expected, and backslash is illegal there (so far).)

Larry