develooper Front page | perl.perl6.language | Postings from August 2005

Re: Demagicalizing pairs

Thread Previous | Thread Next
From:
Damian Conway
Date:
August 24, 2005 00:00
Subject:
Re: Demagicalizing pairs
Message ID:
430C1944.1060302@conway.org
Larry mused:

> On the other hand, I'm not all that attached to colon itself. 

I *am*!!!


> If, as proposed elsewhere, we get rid of the %Foo:: notation in favor of
> some Foo<> variant, then trailing :: becomes available (ignoring ??/::
> for the moment), and
> 
>     new Dog:: tail => 'long'
> 
> almost makes sense, insofar as it kinda looks like it's marking Dog
> as a type name, even though it isn't.  But
> 
>     new Dog:: :tail<long>
> 
> doesn't look so good.

Nor do object methods:

       wag $dog:: 'tail';

       say $fh:: $whatever;



> On the other hand, looking at it from the other end, the MMD notation
> tiebreaking notation is a little hard to spot, since colon is easy
> to miss.

Is it??? I've been writing quite a bit of MMD notation, and I think the colon 
is very obvious...and exactly the right visual "weight".


> Maybe there's something that shows up better in a signature
> that also works as the invocant marker and, by extension, the indirect
> object marker.  Since it's an ordering kind of thing, you'd kind of
> like to work > into it somehow, since the left side is of "greater"
> importance than the left.  Unfortunately, though, "the good ones are
> all taken".  Maybe some digraph like
> 
>     method new ($what*> $:tail) {...}
>     method new ($what+> $:tail) {...}
>     method new ($what.> $:tail) {...}
>     method new ($what|> $:tail) {...}
>     method new ($what>> $:tail) {...}
> 
> giving
> 
>     new Dog*> :tail<long>
>     new Dog+> :tail<long>
>     new Dog.> :tail<long>
>     new Dog|> :tail<long>
>     new Dog>> :tail<long>
> 
> I guess that last one is eqivalent to:
> 
>     method new ($what» $:tail) {...}
>     new Dog» :tail<long>
> 
> which I could maybe get used to.  It kind of looks like a prompt to me.

Not one of these is anything close to as readable as:

     new Dog: :tail<long>

     name $dog: 'Rover';

     say fh:   @whatever

*Please* don't give up on the colon there. It's much more readable. I 
especially like it for setting up objects:

	$person = Contact.new;

	 first_name $person: "George";
	family_name $person: "Bush";
	      title $person: "President";
	      email $person: "daprez@whitehouse.gov";
	     spouse $person: search $contacts: "Laura";


> The ordinary MMD might look like
> 
>     multi foo ($a, $b, $c» $d)
> 
> And Lisp-like MMD fallback on every argument would look like
> 
>     multi foo ($a» $b» $c» $d»)
> 
> I suppose that particular use of » could be construed as encouraging
> people not to do that.  :-)

I truly believe that using the French quotes or (shudder!) their Texan 
equivalents here would be a dire step backwards. They're already overloaded 
for word lists and hyperoperators. I think using them for an invocant marker 
as well would simply be too much.

The colon really was (and still is) the right choice here.

Damian


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About