zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: 4.1: multi-parameter for loop
Date: Thu, 21 Jun 2001 10:33:54 +0200 (MET DST)	[thread overview]
Message-ID: <200106210833.KAA12964@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <Tc0a88d015442f20480@mailsweeper01.cambridgesiliconradio.com>

Peter Stephenson wrote:

> ...
> 
> My main worry is that the wordcode stuff is as clear as mud to me.  In
> particular, I don't know what WC_FOR_SKIP is doing, why it divides the data
> size(?) by 4, and whether it needs changing when there's more stuff in
> the for structure.

>From zsh.h:

  #define WC_FOR_TYPE(C)      (wc_data(C) & 3)
  #define WC_FOR_PPARAM       0
  #define WC_FOR_LIST         1
  #define WC_FOR_COND         2
  #define WC_FOR_SKIP(C)      (wc_data(C) >> 2)
  #define WCB_FOR(T,O)        wc_bld(WC_FOR, ((T) | ((O) << 2)))


For for-loops the data field contains 1) the type of the loop
(positional params, a list of values or a condition) and 2) the offset
to the code after the loop.  The type is stored in the lowest two bits,
the offset is the rest, hence the `>> 2' to get the offset.

And since par_for() calculates the offset at the very end, it already
takes into account your parameter list.


I'd like to have something like this *a lot*.  I've missed it several
times already, I just didn't think of enhancing the for loop syntax.
I don't have any strong feelings pro or contra one of the suggested
syntaxes.  Similar like Bart's `foreach' suggestion, one could also use
`for (a b) in ...' to make this `save', trying to make it look like one
of these tuple assignments that are possible in some languages.  Of
course, people could then come and think that `(a b)=(1 2)' should work,
too.


Bye
  Sven


-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


      parent reply	other threads:[~2001-06-21  8:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-20 14:45 Peter Stephenson
2001-06-20 16:11 ` Peter Stephenson
2001-06-20 18:01 ` Andrej Borsenkow
2001-06-20 18:20   ` Bart Schaefer
2001-06-20 18:39     ` Peter Stephenson
2001-06-20 18:55       ` Bart Schaefer
2001-06-20 19:12         ` Peter Stephenson
2001-06-20 22:56           ` Danek Duvall
2001-06-21  7:19             ` Andrej Borsenkow
2001-06-21  9:52               ` Peter Stephenson
2001-06-21 10:34                 ` PATCH (redux): POSIX `for' syntax Bart Schaefer
2001-06-21 15:31                   ` PATCH (redux): non-POSIX " Peter Stephenson
2001-06-25 16:05                     ` Peter Stephenson
2001-06-21  9:55               ` PATCH: POSIX " Bart Schaefer
2001-06-22  6:29                 ` PATCH: test case for " Andrej Borsenkow
2001-06-22 23:49         ` PATCH: 4.1: multi-parameter for loop Zefram
2001-06-23  0:04           ` Bart Schaefer
2001-06-21  8:33 ` Sven Wischnowsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200106210833.KAA12964@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).