Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #101311

Re: Macro Expansion

From Jean-Marc Bourguet <jm@bourguet.org>
Newsgroups comp.lang.c
Subject Re: Macro Expansion
References <o4rcbl$4cp$1@dont-email.me> <878tqlykwg.fsf@news.bourguet.org> <o4tdl4$1k5$1@dont-email.me> <87r34dwqo9.fsf@news.bourguet.org> <o4ts55$mgl$1@dont-email.me>
Date 2017-01-08 21:43 +0100
Message-ID <87shot5lkx.fsf@news.bourguet.org> (permalink)
Organization Guest of ProXad - France

Show all headers | View raw


BartC <bc@freeuk.com> writes:

> On 08/01/2017 14:51, Jean-Marc Bourguet wrote:
>> BartC <bc@freeuk.com> writes:
>>
>>> But 'a(10)' can also be part of normal code, not inside a macro
>>> definition. Then the 'b' that is generated is in a different 'token-space'
>>> from the "(10)" in the rest of the file (and likely to still exist as
>>> characters not tokens). Rescanning an entirely source file is hopelessly
>>> inefficient just for the off-chance someone might be using such macros.
>>
>> You don't rescan the whole file. The rescan of the expansion is made once
>> more than you though and in its context.
>>
>> You don't know the steps people are ready to avoid using an external tool
>> while still using compact code. The technique is used in practice.  Look
>> for chaos pp and the boost preprocessor library for such kind of techniques
>> (the goal of those libraries is to encapsulate them in an more convenient
>> interface).
>
> I looked at chaos-pp. I didn't know the purpose of your comment and thought
> it was another pre-processor implementation to look at.

Again, it's a library providing a (relatively) high level interface for
intensive C preprocessor usage.  I've looked in the past at the boost
preprocessor library; I'm not really clear about the relationship with
chaos pp, they seem very similar and share an author, I've the vague
impression that chaos-pp both precedes and follows the boost component; at
least there is some documentation -- sadly more a reference than a user
guide -- which include examples.  See for instance
http://www.boost.org/doc/libs/1_63_0/libs/preprocessor/doc/ref/if.html

It is also the more limit-pushing use of the preprocessor that I'm aware
of.  (As limit cases, there is also the fact that some are using the C
preprocessor for other things than C)

> How did a no-nonsense language such as C end up with a dependency on a
> macro language so arcane that apparently few can fully understand it?

Macro language in general are arcane (see TeX for another example, even in
the case of Lisp dialects, macros, as hygienic they may be, are arcane).
That is partially but not uniquely due to the fact that it is another
paradigm than the one we are used to (it's funny to see how the same
techniques are used in TeX and with CPP).

Obviously, you also need to never forget that standardization is design by
comittee per nearly by definition (Ada succeeded in avoiding that for its
first two rounds -- I've not followed after -- but that's the only case I
know and it was quite special with DoD funding).  On those comittee
providers are overrepresented (and have a de facto veto when they agree)
and users which are present are more sophisticated than the common one.

In the case of C, there was the additional factor that it was a comittee
tasked with standardizing something which existed for a relatively long
time, for which the need of a standard appeared due to variation in
behavior between existing implementations (whose users and providers where
in the comittee).

Yours,

-- 
Jean-Marc

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 18:35 +0000
  Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-01-07 11:23 -0800
    Re: Macro Expansion Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-07 21:28 +0000
  Re: Macro Expansion Siri Cruise <chine.bleu@yahoo.com> - 2017-01-07 11:45 -0800
    Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 20:16 +0000
      Re: Macro Expansion Siri Cruise <chine.bleu@yahoo.com> - 2017-01-07 12:23 -0800
        Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 20:31 +0000
          Re: Macro Expansion Siri Cruise <chine.bleu@yahoo.com> - 2017-01-07 12:42 -0800
          Re: Macro Expansion Ian Collins <ian-news@hotmail.com> - 2017-01-08 14:42 +1300
            Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 13:18 +0000
  Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 20:15 +0000
    Re: Macro Expansion Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-07 20:42 +0000
      Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 22:50 +0000
        Re: Macro Expansion Ian Collins <ian-news@hotmail.com> - 2017-01-08 11:59 +1300
          Re: Macro Expansion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-07 15:10 -0800
        Re: Macro Expansion supercat@casperkitty.com - 2017-01-07 17:24 -0800
          Re: Macro Expansion Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-15 21:55 -0800
            Re: Macro Expansion supercat@casperkitty.com - 2017-01-16 09:06 -0800
              Re: Macro Expansion Tim Rentsch <txr@alumni.caltech.edu> - 2017-01-31 08:51 -0800
                Re: Macro Expansion supercat@casperkitty.com - 2017-01-31 13:06 -0800
                Re: Macro Expansion Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-03 07:49 -0800
                Re: Macro Expansion supercat@casperkitty.com - 2017-02-03 12:03 -0800
                Re: Macro Expansion Tim Rentsch <txr@alumni.caltech.edu> - 2017-02-09 09:00 -0800
        Re: Macro Expansion Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-08 01:37 +0000
          Re: Macro Expansion Jean-Marc Bourguet <jm@bourguet.org> - 2017-01-08 10:22 +0100
  Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-01-07 12:18 -0800
    Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 20:28 +0000
      Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-01-07 12:36 -0800
        Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-07 22:59 +0000
  Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-01-08 00:20 -0800
    Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 13:30 +0000
      Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-10 14:00 +0000
        Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-01-10 07:43 -0800
          Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-10 17:47 +0000
            Re: Macro Expansion Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-10 22:49 +0000
              Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-10 23:28 +0000
              Re: Macro Expansion "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-10 18:51 -0500
                Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-11 00:06 +0000
          Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-10 20:30 +0000
            Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-04-26 10:04 -0700
              Re: Macro Expansion Keith Thompson <kst-u@mib.org> - 2017-04-26 12:00 -0700
                Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-04-26 12:24 -0700
              Re: Macro Expansion bartc <bc@freeuk.com> - 2017-04-26 20:12 +0100
                Re: Macro Expansion Thiago Adams <thiago.adams@gmail.com> - 2017-04-26 12:34 -0700
                Re: Macro Expansion jameskuyper@verizon.net - 2017-04-26 13:46 -0700
  Re: Macro Expansion Jean-Marc Bourguet <jm@bourguet.org> - 2017-01-08 10:13 +0100
    Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 13:10 +0000
      Re: Macro Expansion Jean-Marc Bourguet <jm@bourguet.org> - 2017-01-08 15:51 +0100
        Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 17:17 +0000
          Re: Macro Expansion supercat@casperkitty.com - 2017-01-08 11:04 -0800
            Re: Macro Expansion Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-01-08 11:10 -0800
              Re: Macro Expansion supercat@casperkitty.com - 2017-01-08 14:08 -0800
            Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 19:49 +0000
              Re: Macro Expansion supercat@casperkitty.com - 2017-01-08 14:17 -0800
          Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 19:19 +0000
          Re: Macro Expansion Jean-Marc Bourguet <jm@bourguet.org> - 2017-01-08 21:43 +0100
      Re: Macro Expansion supercat@casperkitty.com - 2017-01-08 10:43 -0800
      Re: Macro Expansion Keith Thompson <kst-u@mib.org> - 2017-01-08 12:39 -0800
  Re: Macro Expansion antispam@math.uni.wroc.pl - 2017-01-08 22:54 +0000
    Re: Macro Expansion "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-08 18:36 -0500
      Re: Macro Expansion antispam@math.uni.wroc.pl - 2017-01-09 01:15 +0000
        Re: Macro Expansion "James R. Kuyper" <jameskuyper@verizon.net> - 2017-01-08 20:49 -0500
    Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-08 23:53 +0000
      Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-09 01:11 +0000
      Re: Macro Expansion antispam@math.uni.wroc.pl - 2017-01-09 01:31 +0000
        Re: Macro Expansion BartC <bc@freeuk.com> - 2017-01-10 11:28 +0000

csiph-web