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


Groups > comp.compilers > #381

Re: designing language extensions, was Looking for volunteers for XL

From Marco van de Voort <marcov@toad.stack.nl>
Newsgroups comp.compilers
Subject Re: designing language extensions, was Looking for volunteers for XL
Date 2011-12-03 13:02 +0000
Organization Stack Usenet News Service
Message-ID <11-12-009@comp.compilers> (permalink)
References (1 earlier) <11-11-053@comp.compilers> <11-11-054@comp.compilers> <11-11-061@comp.compilers> <11-11-064@comp.compilers> <11-12-002@comp.compilers>

Show all headers | View raw


On 2011-12-01, Kaz Kylheku <kaz@kylheku.com> wrote:
>> Take the well-known language C, which has a crude mechanism to extend
>> it in the form of its pre-processing macro language.
>>
>> Most enhancements you might want to make to the language, can be
>> achieved by some clunky, ugly macro. But the real problem is that your
>> code now consists of a private, ad-hoc collection of macros which
>> no-one else understands.
>
> That isn't the problem, because collections of macros can be
> well-designed, implemented and documented,

So can brainf*ck code :-) A faulty language doesn't precluding
investing an huge amount of engineering, testing and
adminstration/documentation to manage it.

But that doesn't meant that all languages should be faulty :-)

> Not all the problems in the C preprocessor are in the preprocessor.  Never mind
> that all it can do is substitute, arguments, paste tokens.  produce strings,
> and suck in include files.

Well, that is what (pure) preprocessors do? :-)

If you start adding more knowledge to the preprocessor it becomes a
part of the compiler and language, and your macros are not true macros
anymore, but inlinable functions.

> One big problem is that the target language for macro expansions (C)
> sucks.  For one thing, any syntactic unit that contains declarations
> cannot be an expression that returns a value.

I would write that up to keeping the preprocessor mostly a text
manipulator rather than a compiler, not a target language defect.

A preprocessor that fully understood what it was parsing could hoist
such declarations out of the block if the language needed it?

> Macros that need to generate complex code that requires hidden variables
> automatically have a difficulty in returning a value in a
> function-call-like way, because only expressions do that.  Macros do not
> work well over languages that don't have a uniform syntax that corresponds
> well to the implied abstract syntax trees.

I think this is a symptom of the above. A simple hierarchical
structure is easier to duplicate between preprocessor and compiler,
but it is the barriers that are are part of the definition (separate
binary, textual substitution) that are the main problems.

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Looking for volunteers for XL Christophe de Dinechin <christophe@taodyne.com> - 2011-11-22 21:03 -0800
  Re: Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-11-26 05:43 +0000
  Re: Looking for volunteers for XL Christophe de Dinechin <christophe@taodyne.com> - 2011-11-26 12:38 -0800
    Re: Looking for volunteers for XL "BartC" <bc@freeuk.com> - 2011-11-26 23:19 +0000
      Re: Looking for volunteers for XL Christophe de Dinechin <christophe@taodyne.com> - 2011-11-27 12:34 -0800
        Re: Looking for volunteers for XL "BartC" <bc@freeuk.com> - 2011-11-27 22:24 +0000
          Re: Looking for volunteers for XL Christophe de Dinechin <christophe@taodyne.com> - 2011-11-28 14:12 -0800
            Re: Looking for volunteers for XL ardjussi <jussi.santti@ard.fi> - 2011-11-30 13:16 -0800
              Re: Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-12-01 05:44 +0000
                Re: overloading, was Looking for volunteers for XL glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-12-02 05:36 +0000
          Re: Looking for volunteers for XL tm <thomas.mertes@gmx.at> - 2012-01-03 09:28 -0800
      Re: Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-11-28 04:45 +0000
        Re: Looking for volunteers for XL Timothy Knox <tdk@thelbane.com> - 2011-11-27 22:50 -0800
          Re: Looking for volunteers for XL Alex McDonald <blog@rivadpm.com> - 2011-12-01 12:11 -0800
        Re: Looking for volunteers for XL "BartC" <bc@freeuk.com> - 2011-11-28 10:23 +0000
          Re: Looking for volunteers for XL glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-11-29 07:37 +0000
            Re: macros, Looking for volunteers for XL Gene Wirchenko <genew@ocis.net> - 2011-12-03 17:36 -0800
              Re: macros, Looking for volunteers for XL glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-12-05 04:24 +0000
          Re: Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-12-01 05:35 +0000
            Re: designing language extensions, was Looking for volunteers for XL Marco van de Voort <marcov@toad.stack.nl> - 2011-12-03 13:02 +0000
            Re: Looking for volunteers for XL jgk@panix.com (Joe keane) - 2011-12-13 00:08 +0000
              Re: macros, was Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-12-13 01:39 +0000
                Re: macros, was Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-12-14 19:00 +0000
                Re: macros, was Looking for volunteers for XL jgk@panix.com (Joe keane) - 2011-12-15 15:40 +0000
                Re: macros, was Looking for volunteers for XL Kaz Kylheku <kaz@kylheku.com> - 2011-12-16 17:48 +0000
        Re: Looking for volunteers for XL glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2011-11-28 10:26 +0000

csiph-web