The Lost Language Extensions of MetaWare's High C Compiler
MetaWare's High C Compiler introduced innovative language extensions in the 1980s, including underscores in numeric literals, labeled arguments, case ranges, nested functions, and generator coroutines, influencing modern programming languages.
Read original articleThe article discusses the unique language extensions of MetaWare's High C Compiler, which were developed during the competitive landscape of the 1980s. Unlike modern compilers that focus on platform-specific details, High C introduced several innovative features that enhanced the C programming language. Notable extensions include the use of underscores in numeric literals for better readability, labeled arguments for function calls, case ranges for value matching, and the ability to nest functions, which allows for more expressive programming. High C also featured generator coroutines, enabling functions to yield multiple values, a concept that was ahead of its time compared to later developments in other languages like Python and C++. These extensions provided significant improvements in usability and expressiveness, many of which have only recently been adopted in standard C or C++. The article highlights how these features contributed to the evolution of programming languages and their relevance in modern development.
- MetaWare's High C Compiler introduced several innovative language extensions in the 1980s.
- Features included underscores in numeric literals, labeled arguments, case ranges, and nested functions.
- High C supported generator coroutines, allowing functions to yield multiple values.
- Many of these extensions were not adopted in standard C or C++ until decades later.
- The article emphasizes the impact of these features on the evolution of programming languages.
Related
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
Five little languages and how they grew: Dennis Ritchie's talk at HOPL on the
Dennis M. Ritchie's 1993 HOPL conference transcript compares C with languages like Bliss, Pascal, Algol 68, and BCPL. He discusses similarities, unique features, and design challenges, offering insights into historical context and language development.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.
C Isn't a Programming Language Anymore (2022)
The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.
How to wrap a C compiler and preprocessor, really
The article explores creating a wrapper for C compilers GCC and Clang, proposing a "back-room" approach to simplify modifications during compilation using existing compiler options and addressing integration challenges.
- Several commenters note that many features from High C, such as underscores in literals and named arguments, have been adopted or are present in other languages like D and Ada.
- There is a sense of nostalgia and appreciation for the advanced features of High C, with some expressing regret that these innovations did not influence C standards more significantly.
- Commenters discuss the existence of similar features in GCC and other compilers, indicating a broader trend of evolving programming language capabilities.
- Some users share their experiences with High C and express a desire for unofficial extensions or plugins to enhance C's functionality.
- There is a recognition of the historical context, with some suggesting that the lack of standardization processes may have contributed to the obscurity of these features.
I am fortunate enough to own a copy of the High C/C++ Language Reference in English. (-:
* http://jdebp.uk./FGA/metaware-iterator-driven-for.html
* http://jdebp.uk./Proposals/metaware-iterator-driven-for.html
1. underscores in literals:
int a = 1_234_567;
2. case ranges: case 5 .. case 6:
3. named arguments: void test(int a, int b);
void foo() { test(b:3, a:4); }
4. nested functions: int foo(int i) {
int plus(int a) { return a + i; }
return plus(3);
}
5. static nested functions: int foo(int i) {
static int plus(int a) { return a + i; }
return plus(3);
}
Error: `static` function `test.foo.plus` cannot access variable `i` in frame of function `test.foo`
6. a feature similar to generators https://dlang.org/spec/statement.html#foreach_over_struct_an...Also previously covered here on Hacker News: https://news.ycombinator.com/item?id=38938402
Is there a PDF copy of this somewhere?
Ada has:
- Labels in the form of: Call (Param_A => 1, Param_B => "Foo");
- Underscores can be used in numbers of any base: X : Integer := 1_000;
- Nested subprograms
- Range based tests
I don't know enough about Japanese orthography or keming rules to be sure but it looks very much like they took a variable width font with both kanji and latin characters and then hard formatted it into fixed width cells?
Either way, it's nice that the code examples aren't in 8pt font like a lot of the books I have...
Since it's apparently from Fujitsu, I could see it being the former, but if so, I'm impressed with the quality of the English in the printf statements and code comments from non-native English speakers.
IMHO what I would need with C is a powerful pre-processor like jinja2 and some symbol manipulation features too.
I think these are good ideas.
- Underscores in numeric literals: I think it is a good idea and is also what I had wanted to do before, too. (It should be allowed in hexadecimal as well as decimal)
- Case ranges: GNU C has this feature, too.
- Named arguments: This is possible with GNU C, although it doesn't work without writing it to handle this (although you can use macros to allow it to work with existing functions). You can pass a structure, either directly to the function, or using a macro containing a ({ }) block which extracts the values from the structure and passes them to the function (the compiler will hopefully optimize out this block and just pass the values directly). You can then use the named initialization syntax (which also allows arguments without named), and GNU C also allows you to have duplicates in which case only one of them will work, which allows you to use macros to provide default values. (I have tested this and it works.)
- Nested functions: GNU C also has it, but does not have the "full function value" like this one does, and I think it might be helpful. Nonlocal exits can also be helpful. (I also think the GNU's nested functions could be improved, by allowing them to be declared as "static" and/or "register" in order to avoid the need of trampoline implementations, although "static" and "register" would both have their own additional restrictions; "static" can't access local variables and functions from the function it is contained in unless they are also declared as "static", and "register" means the address can't be taken (therefore allowing the compiler to pass the local variables as arguments to the nested function).)
- Generator functions: I like this too and I think that it is useful (I had wanted things like this before, too). It is also interesting how it can work well with the nested functions.
There are some other things that I also think should be added into a C compiler (in addition to existing GNU extensions), such as:
- Allowing structures to contain members declared as "static". This is a global value whose name is scoped to the strucure within the file being compiled (so, like anything else declared as static, the name is not exported), so any accesses will access the single shared value. Even in the case of e.g. (x->y) if y is a static member then x does not need to be dereferenced so it is OK if it is a null pointer.
- Scoped macros, which work after the preprocessor works. It may be scoped to a function, a {} block inside of a function, a file, a structure, etc. The macro is only expanded where that name is in scope, and not in contexts where a new name is expected (e.g. the name of a variable or argument being declared) (in this case the macro is no longer in scope).
- Allow defining aliases. The name being aliased can be any sequence of bytes (that is valid as a name on the target computer), even if it is not otherwise valid in C (e.g. due to being a reserved word). Any static declaration that does not declare the value may declare the alias.
- Compile-time execution (with explicit declaration).
- Custom output sections, which can be used or moved into standard sections in a portable way. These sections might not even be mapped, and may have assertions, alignment, overlapping, etc.
- Allow functions to be declared as "register". If a function is declared as "static register" (so that the name is not exported), then the compiler is allowed to change the calling convention to work better with the rest of the program.
// Declaration:
void plot(float xlo, float xhi, float ylo, float yhi, float xinc, float yinc);
struct plot_a { float xlo, xhi, ylo, yhi, xinc, yinc; };
static inline void plot_i(struct plot_a _a) {
// inline thunk to allow arguments to be passed in registers
plot(_a.xlo, _a.xhi, _a.ylo, _a.yho, _a.xinc, _a.yinc);
}
#define plot(...) (plot_i((struct plot_a){ __VA_ARGS__ }))
// Call:
plot(alo, ahi, blo*2.0, bhi*2.0, .yinc = y, .xinc = f(x+z));
Pascal lets you match a range of values with case low..high; wouldn't it be great if C had that feature? High C does, another feature standard C and C++ never adopted.
https://gcc.gnu.org/onlinedocs/gcc/Case-Ranges.html Nested functions
https://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html Generators
GCC doesn't do those --- looks like a fun feature though!My favourite, which was sadly removed was doing:
foo ? zork : bork = 123;
Oh well...Related
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
Five little languages and how they grew: Dennis Ritchie's talk at HOPL on the
Dennis M. Ritchie's 1993 HOPL conference transcript compares C with languages like Bliss, Pascal, Algol 68, and BCPL. He discusses similarities, unique features, and design challenges, offering insights into historical context and language development.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.
C Isn't a Programming Language Anymore (2022)
The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.
How to wrap a C compiler and preprocessor, really
The article explores creating a wrapper for C compilers GCC and Clang, proposing a "back-room" approach to simplify modifications during compilation using existing compiler options and addressing integration challenges.