JdeBP
I wrote up the iterator-driven for back in 2011, because it was one of those things that had been long-since forgotten about; along with what it would look like were it to be incorporated into the (then) C++ standard.

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

WalterBright
D (also in Das BetterC) has:

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...
hgs3
Related: The 'lcc-win' C compiler added operator overloading, default function arguments, and function overloading (see "generic functions") [1]. The Plan 9 C compiler introduced several language extensions, some of which, like anonymous structs/unions would eventually be incorporated into the C standard. Present day GCC accepts the -fplan9-extensions flag [2] which enables some nifty features, like automatically converting a struct pointer to an anonymous field for function calls and assignments.

[1] https://lcc-win32.services.net/C-Tutorial.pdf

[2] https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html

bhouston
Who was the genius behind these features? Someone was incredibly forward looking in that company. Too bad it never got out into the world and impacted the language standards. It is surprising to see that so long ago.

Also previously covered here on Hacker News: https://news.ycombinator.com/item?id=38938402

Is there a PDF copy of this somewhere?

stefanos82
Previous submission with comments https://news.ycombinator.com/item?id=38938402
JoshTriplett
For anyone wondering why the string literals in the pictured examples end with ¥n rather than \n, it looks like these code examples were written in Shift-JIS, and Shift-JIS puts ¥ where ASCII has \.
Sad90sNerd
These extensions are Ada features.

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

lexicality
Content aside, I'm fascinated by the typography in this book. It's simultaneously beautiful and horrendous!

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...

nyanpasu64
The generators remind me of Rust's internal/external iteration question and try_fold() (https://scribe.rip/@veedrac/rust-is-slow-and-i-am-the-cure-3...).
omoikane
This seems way ahead of its time, especially with generators. Maybe Fujitsu was able to just do it because they didn't bother with any of the lengthy standardization processes, but that's probably also why all these extensions seemed relatively unknown and had to be rediscovered and reinvented in modern C/C++ decades later.
AdmiralAsshat
Question: Was the book from the screenshots composed in Japanese, or composed in English and then translated into Japanese?

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.

pjmlp
Old memories, I had access to the MS-DOS version of it, still preferred Borland though.
dsp_person
Are there are good unofficial gcc plugins/extensions out there? It would be cool to extend C with a thing or two without adopting a full blown compiler like C2 or C3.
notorandit
I for one think that we have lost a number of good opportunities to make C language a better and .ore powerful one.

IMHO what I would need with C is a powerful pre-processor like jinja2 and some symbol manipulation features too.

zzo38computer
The file does not display because the browser insists on percent-encoding the apostrophe but the server insists that the apostrophe should not be percent-encoded, therefore resulting in an error message that it won't redirect properly. I can download the file properly with curl, though.

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.

mananaysiempre
As a side note, these days you can fake named arguments in C, if you’re OK with every argument being 0 by default:

  // 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));
amszmidt
So ... GCC has had some of these for ages.

    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...