From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27724 invoked from network); 21 Jun 2001 08:35:44 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 Jun 2001 08:35:44 -0000 Received: (qmail 22398 invoked by alias); 21 Jun 2001 08:35:05 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 15019 Received: (qmail 22383 invoked from network); 21 Jun 2001 08:35:04 -0000 From: Sven Wischnowsky Date: Thu, 21 Jun 2001 10:33:54 +0200 (MET DST) Message-Id: <200106210833.KAA12964@beta.informatik.hu-berlin.de> To: zsh-workers@sunsite.dk Subject: Re: PATCH: 4.1: multi-parameter for loop In-Reply-To: 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