On 11.09.2011 11:43, bearophile wrote:
Don:

Do you have an example?

In bug 3849 there the only example I've found (it's not my code):

immutable ubyte _ctype[256] =
[
         _CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,
         _CTL,_CTL|_SPC,_CTL|_SPC,_CTL|_SPC,_CTL|_SPC,_CTL|_SPC,_CTL,_CTL,
         _CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,
         _CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,
         _SPC|_BLK,_PNC,_PNC,_PNC,_PNC,_PNC,_PNC,_PNC,
         _PNC,_PNC,_PNC,_PNC,_PNC,_PNC,_PNC,_PNC,
         _DIG|_HEX,_DIG|_HEX,_DIG|_HEX,_DIG|_HEX,_DIG|_HEX,
         _DIG|_HEX,_DIG|_HEX,_DIG|_HEX,_DIG|_HEX,_DIG|_HEX,
         _PNC,_PNC,_PNC,_PNC,_PNC,_PNC,
         _PNC,_UC|_HEX,_UC|_HEX,_UC|_HEX,_UC|_HEX,_UC|_HEX,_UC|_HEX,_UC,
         _UC,_UC,_UC,_UC,_UC,_UC,_UC,_UC,
         _UC,_UC,_UC,_UC,_UC,_UC,_UC,_UC,
         _UC,_UC,_UC,_PNC,_PNC,_PNC,_PNC,_PNC,
         _PNC,_LC|_HEX,_LC|_HEX,_LC|_HEX,_LC|_HEX,_LC|_HEX,_LC|_HEX,_LC,
         _LC,_LC,_LC,_LC,_LC,_LC,_LC,_LC,
         _LC,_LC,_LC,_LC,_LC,_LC,_LC,_LC,
         _LC,_LC,_LC,_PNC,_PNC,_PNC,_PNC,_CTL, ...
];

(ellipses added by me). But I have never had to do something like that in my 
code, so far.

Thanks! We could do this with CTFE, for example:

immutable ubyte _ctype[256] = padArrayLiteral(256,
        [
          _CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,_CTL,
...
          _LC,_LC,_LC,_PNC,_PNC,_PNC,_PNC,_CTL
        ], 0);

and this would also work with Stewart's example.
I don't think we really need language support, the language already has enough power to do this kind of thing in a library.


Stewart Gordon has recently written more comments about this topic (is Bugzilla 
down?):
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=32924

Bye,
bearophile

Reply via email to