zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <A.Main@dcs.warwick.ac.uk>
To: schaefer@nbn.com
Cc: hzoli@cs.elte.hu, zsh-workers@math.gatech.edu
Subject: Sick macros (was: Action, not words (Re: bug (?) in 3.0-pre1))
Date: Tue, 2 Jul 1996 08:24:37 +0100 (BST)	[thread overview]
Message-ID: <1822.199607020724@stone.dcs.warwick.ac.uk> (raw)
In-Reply-To: <960630145016.ZM12277@candle.brasslantern.com> from "Bart Schaefer" at Jun 30, 96 02:50:13 pm

Bart wrote:
>2.  Introduce macros for heapalloc/permalloc that start with an open
>    brace, and a macro for lastalloc that ends with a close brace, so
>    it's syntatically required that every heapalloc/permalloc have a
>    matching lastalloc.  As this introduces a new block context, use a
>    block-local variable in heapalloc/permalloc to remember the state
>    of the useheap global, and test the block-local in lastalloc to
>    reset the global state appropriately.

Probably a good idea, but as these macros now introduce new syntax
let's make them *look* like syntax, rather than function calls.

The 3.0-pre2-test patch contains:
:+ # define heapalloc() do { \
:+ 			int nonlocal_useheap = useheap; \
:+ 			global_heapalloc()

I recommend changing heapalloc() to heapalloc, and similarly removing
the parentheses for permalloc and lastalloc.

:+ # define lastalloc_return \
:+ 			if (nonlocal_useheap) global_heapalloc(); \
:+ 			else global_permalloc(); \
:+ 			return

This won't work as the body of an if or while.  The following is always
safe:

#define lastalloc_return \
  if( (nonlocal_useheap ? global_heapalloc() : global_permalloc()) , 0 ) \
    ; \
  else \
    return

On a related point, I've been meaning to clean up execerr() in exec.c
for a while:

exec.c contains:
$#define execerr() { if (forked) _exit(1); \
$	closemnodes(mfds); lastval = 1; return; }

This should be

#define execerr \
  do { \
    if(forked) _exit(1); \
    closemnodes(mfds); \
    lastval = 1; \
    return; \
  } while(0)

It should then be invoked as "execerr;", rather than "execerr()"
(whereas it's currently *actually* being invoked as "execerr();").

YYERROR and YYERRORV in parse.c have a similar problem (they need do
... while(0) bracketing -- and this actually affected me when producing
a recent patch).

-zefram



  reply	other threads:[~1996-07-02  7:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-28 17:12 bug (?) in 3.0-pre1 gene
1996-06-28 17:50 ` Zoltan Hidvegi
1996-06-28 19:04   ` Steven L Baur
1996-06-29 19:13   ` Bart Schaefer
1996-06-30 16:13     ` Zoltan Hidvegi
1996-06-30 19:21       ` Bart Schaefer
1996-06-30 21:50         ` Action, not words (Re: bug (?) in 3.0-pre1) Bart Schaefer
1996-07-02  7:24           ` Zefram [this message]
1996-07-02 17:52             ` Sick macros (was: Action, not words (Re: bug (?) in 3.0-pre1)) Bart Schaefer
1996-07-02 18:24               ` Zefram
1996-07-02 19:19                 ` Bart Schaefer

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=1822.199607020724@stone.dcs.warwick.ac.uk \
    --to=a.main@dcs.warwick.ac.uk \
    --cc=hzoli@cs.elte.hu \
    --cc=schaefer@nbn.com \
    --cc=zsh-workers@math.gatech.edu \
    /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).