An inconvenient truth

Denis Koroskin 2korden at gmail.com
Wed Oct 8 07:28:23 PDT 2008


On Wed, 08 Oct 2008 18:09:52 +0400, Aziz K. <aziz.kerim at gmail.com> wrote:

> 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

There are also ‹ and ›, that are much cutier than yours!
They also have a benefit that most of the fonts I've checked do support  
them *and* you can type them using Alt+0139 and Alt+0155 hotkeys (i.e. no  
copy-paste or special keyboard layouts needed) :)

template reduce(F...)
{
     NxNHelper!(F).For!(Args).Result reduce(Args...)(Args args)
     {
         alias NxNHelper!(F).For!(Args) Aux;
         ...
     }
}

now becomes:

template reduce(F...)
{
     NxNHelper‹F›.For‹Args›.Result reduce(Args...)(Args args)
     {
         alias NxNHelper‹F›.For‹Args› Aux;
         ...
     }
}

P.S. Hotkeys may be different on your system, check the Character Map  
utility that comes with Windows for right hotkeys. Their codes are U+2039  
and U+203A.



More information about the Digitalmars-d mailing list