--- Austin Hastings <[EMAIL PROTECTED]> wrote:
> --- Paul <[EMAIL PROTECTED]> wrote:
> > --- Austin Hastings <[EMAIL PROTECTED]> wrote:
> > > Likewise, I could argue that it be called C<=:\> (the
> > > "disgruntled muppet" operator?) since that reflects the
> > > "equals, under reference" symbology. But that's yucky.
> >
> > Shouldn't that be ==:/ (maybe the "severely startled muppet"
> > operator? lol...) A single = would be assignment, but I have
> > no idea how adverbial modification would affect that. Exactly
> > what *would* adverbial assignment be? Would
> > $a =:\ $b
> > be like
> > $a = \$b
Still no input here. Was it a stupid question? :)
> > > sub budgetwise(Int $a, Int $b) {
> > > -1_000_000 <= $a - $b <= 1_000_000; }
> > > my Int $log_rolling, Int $pork_barrel;
> > > $log_rolling = random() * 1.0E9;
> > > $pork_barrel = random() * 1.0E9;
> > > if ($log_rolling eq:budgetwise $pork_barrel)
> > > print "They cost the same, give or take a million dollars.";
> >
> > Is that saying to make budgetwise the comparison operator at the
> > same precedence as eq?
>
> Actually, what I think I'm saying in this case is "replace the do()
> behavior of infix:eq with this sub."
Okay, that clicked. I'm here now.
> Which has kind of startling effects, because then you can also say
> things like this:
>
> sub uniquely(@dest is rw, @src) {
> my $last = @src[0] ~ "1";
> for @src -> $s {
> @dest.push($last = $s) unless $s == $last;
> }
> }
> my @a = <>; # Read all lines from a file.
> my @b =:uniquely @a; # Eat the duplicates
(Apologies: code above reformatted purely in the interest of readable
space, and not considered an improvement. >:O)
Ok, so you replace ='s do{} with uniquely(). The example won't work to
assign to a scalar, right? I think I'm following you, and I like where
you're going.
"My God, it's full of stars...."
> > Wouldn't that be much like saying
> >
> > my sub infix:um(Int$a,Int $b)is equiv(&infix:eq){#c.f.A6p.11
> > -1_000_000 <= $a - $b <= 1_000_000; }
> > if ($log_rolling um $pork_barrel) # etc
>
> Looks right to me, modulo type-casting behavior -- I think yours does
> typechecking and blows up if the types are misaligned enough, while
> mine finds the right infix:= operator, and replaces the actual
> mechanics. (Frankly, I'm not sure what the right behavior of mine is.
> It may be better to think of it as "temporizing" the infix:= operator
> for one expression only. More thought required.)
Good territory to expore.
> > So how does one get a ref in P6 that won't dereference itself???
>
> No idea. I thought that the auto-da-fe^Wautodereference behavior was
> intended to make "loose references" impossible -- that is, you have
> to treat a reference object as an object, always. (Which just means
> more backslashes, I guess.)
>
> > Then we could say
> > my sub infix:embodies ($a,$b) is equiv(&infix:eq) {
> > $a.ref eq $b.ref # unless eq deref's even here.....
> > }
> > if ($x embodies $y) {
> > print "X and Y refer to the same entity\n";
> > }
>
> Maybe you just have to say C<\$a eq \$b> ?
Makes sense to me. Then the right spelling of the above would be
my sub infix:embodies ($a,$b) is equiv(&infix:eq) { \$a eq \$b }
The only reason I didn't put that to begin with was because of a
discussion I saw about arrays deref'ing themselves. Let's try again
with a little more complexity:
my sub infix:embodies(Ref $a is ref,$b is ref)is equiv(&infix:eq){
$a eq $b
}
Could it be this simple? (Granted, for some definition of "simple"....)
If I read this right, it means $a is a referencing alias of the first
argument, $b the second. Could we then say
if (@x embodies @y) { foople() }
and have it DWIM? Would that mean (in P5-speak) $a->[0] *IS* @x[0] ???
Because if so, then that's exactly what Larry was talking about. The
"cruft" has been sucked back up into the signature where the coder had
to work out the details *once*, and then the code of the operator is
deafeningly simple, as is it use.
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com