Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: why not promote the plague ? (brace|rc|alternative|modern) syntax



On Fri, Dec 13, 2024, at 6:05 PM, Marc Chantreux wrote:
> you don't even need braces. so actually both are working by default:
>
> 	for a in foo bar baz; echo $a
> 	for a ( foo bar baz ) echo $a
>
> this works
>
> 	integer i=10; while (( --i ))  echo $i
>
> this doesn't
>
> 	integer i=10; while (( --i ));  echo $i
>
> both of them work
>
> 	integer i=10; repeat 10; echo $[i--]
> 	integer i=10; repeat 10 echo $[i--]

Mikael's point was to distinguish between the alternative forms
and the SHORT_LOOPS forms.  None of your examples works without
SHORT_LOOPS:

	% unsetopt SHORT_LOOPS
	% for a in foo bar baz; echo $a
	zsh: parse error near `echo'
	% for a ( foo bar baz ) echo $a
	zsh: parse error near `echo'
	% integer i=10; while (( --i )) echo $i
	zsh: parse error near `echo'
	% integer i=10; repeat 10; echo $[i--]
	zsh: parse error near `echo'
	% integer i=10; repeat 10 echo $[i--]
	zsh: parse error near `echo'

-- 
vq




Messages sorted by: Reverse Date, Date, Thread, Author