9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] multiple inputs
Date: Thu,  1 Apr 2004 11:26:12 -0500	[thread overview]
Message-ID: <406C42A4.8000607@swtch.com> (raw)
In-Reply-To: <cc59a5b4b981440e405f12822643ee6b@vitanuova.com>

rog@vitanuova.com wrote:

>>What do the 9fans think of hygenic macros?
>>    
>>
>
>dunno what others think but i reckon macros (hygienic or not) make it
>much harder to maintain a program.  you have to get through the custom
>syntax before you can start seeing what's really going on.
>
>if you need that kind of expressivity, consider writing an
>interpreter, a translator or a preprocessor.
>  
>

I think it would be great if the C compiler had some sort
of nice extension facility (call it hygenic macros with syntax) so that
we could write

alt {
<- done =>
    print("done\n");
c <-= val =>
    print("sent val\n");
}

But you're right, that would make it much harder to maintain
the program.  Instead we should content ourselves with writing

Alt alts[3];
alts[0].c = done;
alts[0].v = 0;
alts[0].op = CHANRCV;
alts[1].c = c;
alts[1].v = val;
alts[1].op = CHANSND;
alts[2].op = CHANEND;
switch(alt(alts)){
case 0:
    print("done\n");
    break;
case 1:
    print("sent val\n");
    break;
}

which is much clearer and doesn't require us to wade through
custom macro syntax.

Russ






  parent reply	other threads:[~2004-04-01 16:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-30  6:53 npe
2004-03-30  8:22 ` matt
2004-03-30 11:48   ` glenda
2004-03-30 14:03     ` matt
2004-03-30 12:10       ` glenda
2004-03-30 16:07         ` rog
2004-03-30 14:15           ` Noah Evans
2004-03-30 16:25         ` rog
2004-03-30 16:14           ` Noah Evans
2004-03-30 18:27             ` rog
2004-03-30 16:28               ` Noah Evans
2004-03-31 20:22             ` boyd, rounin
2004-04-01 13:01               ` Noah Evans
2004-04-01 15:31                 ` rog
2004-04-01 14:43                   ` boyd, rounin
2004-04-01 16:26                   ` Russ Cox [this message]
2004-04-01 17:36                     ` rog
2004-04-01 15:58                       ` Noah Evans
2004-04-01 18:42                         ` rog
2004-04-01 17:34                           ` Noah Evans
2004-04-01 19:47                             ` rog
2004-04-01 18:02                               ` Noah Evans
2004-04-02  1:48                                 ` Geoff Collyer
2004-04-01 20:04                             ` David Tolpin
2004-04-02  1:46                     ` Geoff Collyer
2004-04-02  2:09 Noah Evans

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=406C42A4.8000607@swtch.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.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.
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).