Larry Wall wrote:

On Wed, Feb 09, 2005 at 10:04:48AM +0100, Michele Dondi wrote:
: On Tue, 8 Feb 2005, Matt Fowles wrote:
: : > pipe dreams
: > Juerd wondered if he could mix = and ==> in a sane way. The answer
: > appears to be no. Once you bring in ==> you should stick with it.
: : Huh?!? It doesn't seem to me that the answer is 'no'. In fact C<< ==> >> : is supposed to be yet another operator, albeit somewhat a special one. If : I got it right the answer is actually 'yes': what Larry suggested is that : it would be _stylistically_ better to stick with it once it is used in the : first place.


Yes, you can certainly intermix them as long as you keep your
precedence straight with parentheses.  Though I suppose we could go
as far as to say that = is only scalar assignment, and you have to
use <== or ==> for list assignment.  That would be...interesting...to
say the least.  For instance, it would eliminate the guessing games
about whether the syntactic form of the left side indicates a list.
Doubtless there would be some downsides too...

Larry

I have to say that my initial reaction to this was one of disgust, but the more I think about it, the more I am warming to the idea of having a more robust method of declaring list context vs scalar context.


Issues that arise (my mind has yet to settle enough to label them "downsides"):


- List assignment is way too common to inflict a three char operator on, especially one that really likes having \S around it. (But don't ask me what else to use, not much is left available.) At least, it's way too common for me.

- orthogonality says that we would then need a left scalar assignment operator to mimic ==>. Linguistically, this is "Calculate all this, then stuff the result into $x". This would be very nifty when building long self-referring assignments, because the assignment appears after the expression which used the previous value, which just "flows" better. <Insert arguments about why conditional predicates are a good idea>.

- Would C<< @x = @y; >> then mean C<< @x := @y; >>?

- Somehow, C<< %x <== %y; >> feels very, very wrong.



Pluses:

- I've often considered list assignment to be one of the most useful and subtle things that makes Perl Perl, especially when combined with hash/array slices. However, attempting to bring less monkish fellows up to enlightenment often encounters mental blocks. This might help, having a different syntax makes it significantly less 'magical'. (even though Magic is Good, imho)


I should probably stop rambling now and get some sleep.

-- Rod Adams






Reply via email to