D - more or less power than C++?

Georg Wrede georg.wrede at nospam.org
Sun Mar 5 18:09:37 PST 2006


Walter Bright wrote:

> Should D support trigraphs?


No. Period!



A language that is 32-bit only (meaning no 16-bit processors), just does 
not need them.

32-bit development is done on 32-bit systems. And today all such systems 
use character sets large enough to _at_least_ support the full USASCII 
character set, if not even Unicode as such.

Trigraphs were [thought to be] needed on 7-bit character set systems in 
"Foreign Countries". But that's history there too by now.

Take it from the trenches! :-)

----

There's another issue that some might start arguing. That's keyboard 
layouts.

On exotic layouts some of the main trigraph "target" characters are 
either impossible or just awkward to type. But in those cases it is 
usual to switch between a "native" and the "us" character layout for 
programming. Single click keyboard layout switching is becoming standard 
issue even outside Linux/Windows/Mac.

The C-family of languages is famous for its choice of several source 
code characters being based on their location on the keyboard. The 
people who'd like trigraphs for layout reasons, are likely to have other 
problems too: where are '*@"$&` and some others?

Same problem, but no trigraphs for them.

----

A historical note: They never were more than a make-believe solution for 
"other peoples' problem". In the good Old Days, when we would have 
needed trigraphs, we still didn't use them.

> /*
>   A std C program that includes all the defined trigraphs,
>   Copied from Wikipedia
> */
> ??=include <stdio.h> // #
> 
> int main(void)
> ??< // {
>         char n??(5??); // [ and ]
> 
>         n??(4??) = 'a';
>         printf("%c??/n", n??(4??)); // ??/ = \
>         
>         return ??- 0 ??' 1 ??! 2; // ~, ^ and |
> ??> // }

Now, here's how we used to write the same code, at the time. Granted, 
it's not nice looking to the untrained eye, but using trigraphs (as 
above) would have made the code simply useless.

> /*
>   The same as above.
> */
> £include <stdio.h>
> 
> int main(void)
> ä
>         char Ä5Å;
> 
>         nÄ4Å = 'a';
>         printf("%cÖn", nÄ4Å);
>         
>         return Ü 0 ü 1 ö 2;
> å

Incidentally, this same technique was usable (and was used) in all of 
the countries where non-US versions of ASCII were in use. It's based on 
the fact that any replacement of a US character was both typeable and 
printable. :-)

----

Last, but not least: the problem trigraphs seek to remedy, is such 
pre-ancient history that it should not even be mentioned with a modern 
programming language.



More information about the Digitalmars-d mailing list