Path: csiph.com!weretis.net!feeder9.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: George Neuner Newsgroups: comp.compilers Subject: Re: A tiny self-hosting compiler used for teaching Date: Sat, 05 Sep 2026 14:02:25 -0400 Organization: Compilers Central Sender: johnl%iecc.com Approved: comp.compilers@iecc.com Message-ID: <26-09-006@comp.compilers> References: <26-08-007@comp.compilers> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="29195"; mail-complaints-to="abuse@iecc.com" Keywords: courses, comment Posted-Date: 07 Sep 2026 11:32:37 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:3758 On Tue, 25 Aug 2026 08:05:06 +0200, Michael Lehn 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. IMO, the main reasons that Pascal declarations were easier are: 1) variable names are not intermixed with their types 2) complex types generally require one or more type declarations and can't be declared inline in a variable declaration WRT your examples (and ignoring array base issues), in Pascal the array of pointers is no problem /because/ the base type of the array is simple, however the pointer to array can't be declared in one step because the array itself is not a simple type. type tenInts = array [1..10] of integer; var a : array [1..10] of ^integer; { array of 10 pointers to int } b : ^tenInts; { pointer to array of 10 ints } Yes, reading the declaration for 'b', you do have to go search out the declaration of 'tenInts', but what you don't have to do is decipher a string of line noise to understand the type. Of course, in C you could typedef the array and declare 'b' as a pointer to it - but most programmers would never think to do that with such a "simple" declaration. Few even would bother declaring 'b' a "pointer to array of int" when "pointer to int" will work just as well. [ignoring potential for error checking by the compiler.] And, of course, if you want a Pascal-like language with more functional parity to C there were/are extended and OO Pascals, and derivatives like Modula 2, 2+, 3, etc. >That is almost the whole idea behind A Better C: it is basically C, but with >declarations following a Pascal-like logic. Since `^` already has a meaning in >C, I used `->` for pointers. Yeah ... but what do the declarations look like? Unless you totally changed the syntax, just changing what token(s) denote a "pointer" or a "dereference" operation is no more helpful than is the original C. YMMV. [Your moderator has only limited sympathy for arguments about the aesthetics of declarations, noting a strong pattern of people liking what they learned first. Personally, I think Fortran EQUIVALENCE and COMMON statements are totally intuituitive, but then I would. -John]