Re: A tiny self-hosting compiler used for teaching

Michael Lehn <michael.lehn@uni-ulm.de>
Sat, 05 Sep 2026 19:50:40 -0700

          From comp.compilers

Related articles
[3 earlier articles]
Re: A tiny self-hosting compiler used for teaching thanks-to@Taf.com (CóilínNioclásínGlostéir) (2026-09-04)
Re: A tiny self-hosting compiler used for teaching ram@zedat.fu-berlin.de (2026-09-05)
Re: A tiny self-hosting compiler used for teaching gneuner2@comcast.net (George Neuner) (2026-09-05)
Re: A tiny self-hosting compiler used for teaching ram@zedat.fu-berlin.de (2026-09-05)
Re: A tiny self-hosting compiler used for teaching gneuner2@comcast.net (George Neuner) (2026-09-05)
Re: A tiny self-hosting compiler used for teaching michael.lehn@uni-ulm.de (Michael Lehn) (2026-09-05)
Re: A tiny self-hosting compiler used for teaching michael.lehn@uni-ulm.de (Michael Lehn) (2026-09-05)
Re: A tiny self-hosting compiler used for teaching gneuner2@comcast.net (George Neuner) (2026-09-07)
Re: A tiny self-hosting compiler used for teaching christopher.f.clark@compiler-resources.com (Christopher F Clark) (2026-09-07)
Re: A tiny self-hosting compiler used for teaching michael.lehn@me.com (Michael Lehn) (2026-09-05)
Re: A tiny self-hosting compiler used for teaching ram@zedat.fu-berlin.de (2026-09-08)
Re: A tiny self-hosting compiler used for teaching martin@gkc.org.uk (Martin Ward) (2026-09-09)
| List of all articles for this month |
From: Michael Lehn <michael.lehn@uni-ulm.de>
Newsgroups: comp.compilers
Date: Sat, 05 Sep 2026 19:50:40 -0700
Organization: Compilers Central
References: 26-09-004
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="31382"; mail-complaints-to="abuse@iecc.com"
Keywords: courses
Posted-Date: 07 Sep 2026 11:35:54 EDT
In-Reply-To: 26-09-004



> On 5. Sep 2026, at 17:18, George Neuner <gneuner2@comcast.net> wrote:
> On Tue, 25 Aug 2026 08:05:06 +0200, Michael Lehn
> <michael.lehn@uni-ulm.de> wrote:
>> The main motivation for A Better C is actually quite mundane. When teaching C,
>> I always found declarations unnecessarily difficult to explain. For example:


>> int *a[10]; // array of 10 pointers to int


>> int (*b)[10]; // pointer to an array of 10 ints
>


>> There is a perfectly consistent logic behind C declarations: you declare an
>> object in a form resembling how it is used. But for beginners this means that
>> they already need to understand operator precedence — in particular that
>> postfix operators bind more strongly than prefix operators — just to read a
>> declaration.


>> I learned Pascal before C myself, and always found Pascal declarations easier
>> to read because you can essentially read them from left to right.


> I also learned Pascal before C, and I always have preferred
> Pascal-like syntax to the line noise that is typical of C. Ironically
> most of my career was spent using C++, SQL and Scheme. ...






Yes, I did totally change the declaration syntax. That is the point. :-)


The two declarations look like this in ABC:




        a: array[10] of -> int;
        b: -> array[10] of int;




Thus, `a` is an array of ten pointers to integers, whereas `b` is a pointer to
an array of ten integers.


The variable name is separated from its type, and the type itself can be read
from left to right. `->` is a prefix type constructor, rather than merely a
replacement for `*` within C’s declaration syntax. No parentheses or knowledge
of expression-operator precedence are required to distinguish the two types.


The same principle also applies to more complicated types. For example:






        f: -> fn();
        g: -> fn(value: int);
        h: -> fn(value: int): int;




declare pointers to functions with increasingly detailed parameter and return
types.


ABC is not intended to suggest that Pascal, Modula-2, or related languages did
not already solve this problem. Quite the opposite: it deliberately preserves
their clearer declaration logic while retaining C-like expressions and a low-
level programming model.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.