Re: plaintive whine about 'for' syntax

2002-10-31 Thread Damian Conway
Ed Peschko wrote:

Larry Wall writes:



I think decent formatting would make it clearer:

fora;   b
   - $x is rw; y {
  $x = $y[5];
}



But this isn't very scalable:


Sure it is. You just have to think more two-dimensionally...

for  a;  b;  c;  d;  e
 -  $a_variable1 is rw, $a_variable2 is rw;
  $b_variable is rw;
   $c_variable  is rw;
$d_variable is rw;
 $e_variable1 is rw, $e_variable2 is rw
{
}

:-)

BTW, Both Larry and I do understand the appeal of interleaving
sources and iterators. We did consider it at some length back
in January, when we spent a week thrashing this syntax out.

Of course, I can't speak for Larry, but in the end I concluded
that interleaving iterator variables is a false win, since it
trades reduced syntactic complexity for increased semantic
complexity, but only really improves the readability of a
comparatively rare case.

Damian




Re: plaintive whine about 'for' syntax

2002-10-31 Thread fearcadi
Damian Conway writes:
  
  BTW, Both Larry and I do understand the appeal of interleaving
  sources and iterators. We did consider it at some length back
  in January, when we spent a week thrashing this syntax out.
  
  Of course, I can't speak for Larry, but in the end I concluded
  that interleaving iterator variables is a false win, since it
  trades reduced syntactic complexity for increased semantic
  complexity, but only really improves the readability of a
  comparatively rare case.
  
  Damian
  

but why ? I am just curious about details. 
is it complicated for immediate component of for loop ( mentioned by 
Larry Wall ) to cut-and-paste to reconstruct the original stream list
and block signature. 


1) for  a - $x ; b - $y   { ... } 

 ===

2) for  a ; b - $x ; $y   { ... } 

at the price of - not being consistently closure declarator
*everywhere* and having a bit different meaning inside for ( and only
for , because all other topicalizers dont know about streams -- am I
right ?) . Which it is already not exactly , since immediate component 
of for loop preprocess the closure signature to match the streams . 

and besides, it seems to me that both 1) and 2) can coexist since  for 
loop can controll what happens between for and {...} . but maybe I
am wrong. 

I am just curious . 

arcadi . 



Re: plaintive whine about 'for' syntax

2002-10-31 Thread Simon Cozens
[EMAIL PROTECTED] writes:
 1) for  @a - $x ; @b - $y   { ... } 
 
  ===
 
 2) for  @a ; @b - $x ; $y   { ... } 

You've got it! Semicolon naturally breaks things apart, not groups them
together!

-- 
Anything to do with HTML processing /usually/ involves a pact
with an evil supernatural being, I find.
-- Sean Burke



Re: plaintive whine about 'for' syntax

2002-10-31 Thread Iain 'Spoon' Truskett
* Ed Peschko ([EMAIL PROTECTED]) [01 Nov 2002 07:19]:

[...]
 for @a - $a_variable1 is rw, $a_variable2 is rw;
   @b - $b_variable  is rw;
   @c - $c_variable  is rw;
   @d - $d_variable  is rw;
   @e - $e_variable1 is rw, $e_variable2 is rw;
 {
 }

 is much, *much* clearer. IMO the current 'for' syntax suffers from
 action at a distance, even if that distance is within the same line.
 Related things aren't paired up nearly close enough to each other.

Give this man a +1. I do prefer to have associated things placed
with each other. And, as Simon pointed out, ';' is used to break
things apart, thus the syntax above makes somewhat more sense.

The best part is that I can easily comment out, delete, add part of
the expression without worrying that I'm deleting the wrong thing.

It may not be often that I will use the construct for multiple
iterators, but I can foreseeably use at least 2, and with the
added ease I can imagine using more =)


cheers,
-- 
Iain.



Re: plaintive whine about 'for' syntax

2002-10-31 Thread John Siracusa
On 10/31/02 5:33 PM, [EMAIL PROTECTED] wrote:
 Damian Conway writes:
 BTW, Both Larry and I do understand the appeal of interleaving
 sources and iterators. We did consider it at some length back
 in January, when we spent a week thrashing this syntax out.
 
 Of course, I can't speak for Larry, but in the end I concluded
 that interleaving iterator variables is a false win, since it
 trades reduced syntactic complexity for increased semantic
 complexity, but only really improves the readability of a
 comparatively rare case.
 
 but why ? I am just curious about details.

Yeah, I'd like to hear those details too, because the alternate syntax:

 1) for  @a - $x ; @b - $y   { ... }

sure looks a lot more attractive and sensible to me, and I agree with all
the arguments in favor of it so far.  In particular:

* No look here, then look there connection between (possibly) widely
separated items.

* Simple to add or remove/comment-out individual stream/item(s) pairs
without having to count what are essentially positional parameters to make
sure you haven't mis-mapped anything in the process.

* More familiar use of the semicolon (IMO)

-John




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Michael Lazzaro

On Wednesday, October 30, 2002, at 12:48  PM, Dave Storrs wrote:

	for a; b - $x is rw; $y { $x = $y[5] };


I agree that it's an eyeful.  How many of your issues could be solved 
if the above were just written:

	for (a;b) - ($x is rw; $y) { $x = $y[5] };


Would that suffice to make it clearer?

MikeL



Re: plaintive whine about 'for' syntax

2002-10-30 Thread fearcadi
Michael Lazzaro writes:
  
  On Wednesday, October 30, 2002, at 12:48  PM, Dave Storrs wrote:
  for a; b - $x is rw; $y { $x = $y[5] };
  
  I agree that it's an eyeful.  How many of your issues could be solved 
  if the above were just written:
  
   for (a;b) - ($x is rw; $y) { $x = $y[5] };
  
  
  Would that suffice to make it clearer?
  
  MikeL


in principle , as I understand , initially the choice of single - in
the for loop was because that makes it cute substitute for sub
and makes for loop (almost) a function . 
But for is not a function it makes some grammar magic before real
work. e.g , different meaning of ; inside closure signature . 
so why not to allow it to make also special meaning of - ? So that it 
is not exactly sub declaration but sort of ; and then immediate
component (macro - from one of couple-of-days-ago posts of Larry Wall ) 
of for loop will cut and paste to reconstruct incoming
stream list and closure signature . 


 for a - $x is rw;
 b - $y 
  { $x = $y[5] };

; between for and { ... } cannot be misinterpreted because parser
know it have to get to { ... } . That means for loop without block is
illegal . 

and the () can be placed wherever one please here , they just mean
grouping . 

aracadi 



Re: plaintive whine about 'for' syntax

2002-10-30 Thread Dave Storrs


On Wed, 30 Oct 2002, Michael Lazzaro wrote:

 On Wednesday, October 30, 2002, at 12:48  PM, Dave Storrs wrote:
  for a; b - $x is rw; $y { $x = $y[5] };

 I agree that it's an eyeful.  How many of your issues could be solved
 if the above were just written:

   for (a;b) - ($x is rw; $y) { $x = $y[5] };

 Would that suffice to make it clearer?

Actually, yes, that would solve everything for me...and I knew
this was valid syntax.  However, (A) the fact that Larry went to some
fairly serious lengths to eliminate the need for parens everywhere he
could says to me that we should find a system that doesn't require them
and (B) since it CAN be written in the 'eyeful' way (*) it WILL be written
in that way...and I and others are going to have to maintain code that
uses that and, as I said, I think it's going to lead to a lot of bugs.
Maybe I'm the only one who is bothered by this...if so, I'll cope and
deal.


--Dks




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Damian Conway
Dave Storrs wrote:


	for a; b - $x is rw; $y { $x = $y[5] };


I agree that it's an eyeful.  How many of your issues could be solved
if the above were just written:

	for (a;b) - ($x is rw; $y) { $x = $y[5] };

Would that suffice to make it clearer?



	Actually, yes, that would solve everything for me...and I knew
this was valid syntax.  

So is this vertical layout, which I think will become fairly standard
amongst those who care about readability:

	for a   ; b
 - $x is rw ; $y   { $x = $y[5] };

Damian




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Dave Storrs


On Wed, 30 Oct 2002, Austin Hastings wrote:


 --- Dave Storrs [EMAIL PROTECTED] wrote:

  for @a - $x; @b - $y { $x = $y[5] };

 Yes!!!

 (Except for the ''. That's feigen-ugly.

*shrug*  You may not like the aesthetics, but my point still
stands:  is rw is too long for something we're going to do fairly often.
Give me any one- or two- character marker you want that means rw (if
ro is the default) or r (if rw is the default).

 I prefer default=ro, though,
 because that let's the optimizer do more by default.)

I don't feel strongly enough about this to argue it.  Personally,
I prioritize readablility over ease-of-optimization...I let Moore's law
take care of speed.  Other people, who work in other problem domains than
I do, may need to have other priorities.

 I proposed the multiple arrow thing a long while back, but it didn't
 work out because of precedence with comma and because of
 topicalizing/binding/etc.

 But that was before semicolon which can have a different precedence
 from arrow. And screw the binding -- it just looks right:

 for @first - $a;
 @pairs - $b is rw, $c;
 {
   print woo-hoo!\n;
 }

You're right, that does look good...but you had to manually insert
whitespace in to make it look good.  And (assuming that you used a TAB to
indent the '@pairs...' line), assuming that my TAB settings are the same
as yours.

The problem is, if we make those assumptions, I can even make the
current syntax look (reasonably) good:

for @a;   @b
- $x is rw;  $y
{

}


--Dks




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Larry Wall
On Wed, 30 Oct 2002, Michael Lazzaro wrote:
: On Wednesday, October 30, 2002, at 12:48  PM, Dave Storrs wrote:
:  for a; b - $x is rw; $y { $x = $y[5] };
: 
: I agree that it's an eyeful.  How many of your issues could be solved 
: if the above were just written:
: 
:   for (a;b) - ($x is rw; $y) { $x = $y[5] };
: 
: Would that suffice to make it clearer?

I think decent formatting would make it clearer:

for a  ; b
 - $x is rw; $y {
$x = $y[5];
}

But just a single line break helps a lot:

for a; b
- $x is rw; $y { $x = $y[5] };

But adding parens into a signature might actually make it incorrect,
depending on whether we go with [] or () for subsignatures.  And putting
parens around (a;b) is likely to produce [a],[b], which would
bind to the signature wrong regardless of how it was written.

Larry




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Dave Storrs


On Thu, 31 Oct 2002, Damian Conway wrote:

 Dave Storrs wrote:

  Actually, yes, that would solve everything for me...and I knew
  this was valid syntax.

 So is this vertical layout, which I think will become fairly standard
 amongst those who care about readability:

   for a   ; b
   - $x is rw ; $y   { $x = $y[5] };


To be honest, this just makes it less readable for me.


--Dks




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Angel Faus
Wednesday 30 October 2002 22:08, Michael Lazzaro escribió:
 On Wednesday, October 30, 2002, at 12:48  PM, Dave Storrs wrote:
  for a; b - $x is rw; $y { $x = $y[5] };

 I agree that it's an eyeful.  How many of your issues could be
 solved if the above were just written:

   for (a;b) - ($x is rw; $y) { $x = $y[5] };


 Would that suffice to make it clearer?

 MikeL

Then let's make the parens required when there is more than one 
stream.

Sane people will put them there anyway, and it will force the rest of 
us to behave.

It also solves the ;-not-a-line-seperator problem. 

-angel




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Dave Storrs


On Wed, 30 Oct 2002, Angel Faus wrote:

 Then let's make the parens required when there is more than one
 stream.

 Sane people will put them there anyway, and it will force the rest of
 us to behave.

 It also solves the ;-not-a-line-seperator problem.

 -angel


Yes!  Thank you, this is perfect.  Minimal disruption of the
syntax Larry designed, minimal exception to remember, and it completely
resolves all my issues.  See, I knew there had to be a simple, elegant
solution I was missing.


--Dks




Re: plaintive whine about 'for' syntax

2002-10-30 Thread fearcadi
Dave Storrs writes:
  
  
  On Wed, 30 Oct 2002, Angel Faus wrote:
  
   Then let's make the parens required when there is more than one
   stream.
  
   Sane people will put them there anyway, and it will force the rest of
   us to behave.
  
   It also solves the ;-not-a-line-seperator problem.
  
   -angel
  
  
   Yes!  Thank you, this is perfect.  Minimal disruption of the
  syntax Larry designed, minimal exception to remember, and it completely
  resolves all my issues.  See, I knew there had to be a simple, elegant
  solution I was missing.
  
  
  --Dks
  
  
  

but this will make 

for ( a ; b ) - ( $x ; $y ) { ... } 

to do not what you mean : 

Because it is this : 

for [a] , [b] - $x ; $y { ... $x,$y  are array refs here } 


; is dangerous because it impose scalar context on both sides. 
by enclosing  ( a;b) in () you hide a;b from grammar magic that
for is doing , so for do not know how to bind the streams to
closure args. 

aracdi
   



Re: plaintive whine about 'for' syntax

2002-10-30 Thread Graham Barr
On Wed, Oct 30, 2002 at 01:57:00PM -0800, Dave Storrs wrote:
   *shrug*  You may not like the aesthetics, but my point still
 stands:  is rw is too long for something we're going to do fairly often.

I am not so sure. If I look back through a lot of my code, there are more cases
where I use the variable in a read-only fashion than I do for modifying
the value.

Graham.




Re: plaintive whine about 'for' syntax

2002-10-30 Thread Simon Cozens
[EMAIL PROTECTED] (Dave Storrs) writes:
 minimal exception to remember

Another one for my irregularity check, thanks! :)

-- 
Though spring is here, to me it's still September,
 That September, in the rain
 - Dinah Washington, The USENET Anthem.



Re: plaintive whine about 'for' syntax

2002-10-30 Thread Dave Storrs


On Wed, 30 Oct 2002, Graham Barr wrote:

 On Wed, Oct 30, 2002 at 01:57:00PM -0800, Dave Storrs wrote:
  *shrug*  You may not like the aesthetics, but my point still
  stands:  is rw is too long for something we're going to do fairly often.

 I am not so sure. If I look back through a lot of my code, there are more cases
 where I use the variable in a read-only fashion than I do for modifying
 the value.

Ok, fair enough.

--Dks