scsh-users
[Top] [All Lists]

Re: awk macro misuse?

To: Steve Elkins <sgelkins@bellsouth.net>
Subject: Re: awk macro misuse?
From: RT Happe <rthappe@mathematik.uni-freiburg.de>
Date: Sun, 27 Oct 2002 19:19:07 +0100 (CET)
Cc: <scsh-news@zurich.ai.mit.edu>
On 27 Oct 2002, Steve Elkins wrote:

> Does what follows reveal a bug or am I misusing the awk macro?

Basically, you are ignoring the following passage of the Scsh manual, just
before 8.2.1:

  If there is no after clause, awk returns the loop's state variables as
  multiple values.

> Now wrap it in -e ...
> Error: returning zero values when one is expected
>        (values)
> Other versions used force-output to make the error appear at the end.
> Now put (zap '!) in <state-var-decls> ...
> Why does wrapping the expression in -e cause the error and why does
> adding (zap '!) to <state-var-decls> fix/conceal it?

Here's what I think happens:  in the first version, since you run the code
as a script, the continuation K that eats the value(s) of the LET form
accepts any number of values.  But the LET form returns the value(s) of
the AWK form, therefore the latter may return 0 values as it actually
does (since there are no state variables).  In the second case, since you
have wrapped the LET form in the entry procedure, the continuation K
expects 1 value.  (The entry procedure should return the exit status or
so, in other words, it is called in a context requiring a single return
value.)  But the AWK form still returns nothing, and that's not enough
here.  In the third version, the AWK form has got 1 loop variable instead
of 0 before, and consequently 1 return value, just what the continuation
expects.  That is, repent and change your ways, it was your fault.

rthappe



<Prev in Thread] Current Thread [Next in Thread>