An inconvenient truth

Aziz K. aziz.kerim at gmail.com
Wed Oct 8 07:09:52 PDT 2008


On Wed, 08 Oct 2008 14:21:02 +0200, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> Walter discovered a showstopper for the curls.
>
> class A : B
> {
> }
>
>
> Andrei

How about if we leave the current syntax as it is and introduce an  
alternative syntax using Unicode mathematical letters?
Here's a template function using the Unicode angle brackets "〈〉":

template ToString〈ulong U〉
{
     static if (U < 10)
	const char[] ToString = "" ~ cast(char)(U + '0');
     else
	const char[] ToString = ToString〈U / 10〉 ~ ToString〈U % 10〉;
}

The advantages:

*) Programmers can still use the normal ASCII template instantiation  
syntax.
*) The new syntax doesn't create any grammar ambiguities.
*) More potential converts from the C++ world.

The disadvantages:

*) Using the angle brackets would require some effort, although smart  
editors could alleviate this problem if it detects that an identifier is a  
template or if you specify a macro that turns <- into 〈 and -> into 〉.
*) Practically any font I tried in kwrite/kate didn't render the angle  
brackets at all and instead showed a rectangular box. Interestingly enough  
a few other special Unicode mathematical characters are rendered correctly.

Here is a nice page of all mathematical Unicode characters:  
http://tlt.its.psu.edu/suggestions/international/bylanguage/mathchart.html



More information about the Digitalmars-d mailing list