Revised RFC on range design for D2

Walter Bright newshound1 at digitalmars.com
Wed Oct 1 17:21:15 PDT 2008


Andrei Alexandrescu wrote:
> In neither case is it possible for x and &x to mean the same thing. For 
> functions some really weird stuff happens:

One flag that something wacky is going is to look at the compiler code 
needed to implement it. In DMC, there's the nutty function arraytoptr() 
which is called from about 30 places in the semantic analysis. It's 
clearly a special case:

/**************************
  * If e is <array of>, convert it to <pointer to>.
  * If e is <function>, convert it to <pointer to><function>.
  */

elem *arraytoptr(elem *e)
{   type *t;

     t = e->ET;
     if (t)
     {
         switch (tybasic(t->Tty))
         {   case TYarray:
                 if (e->Eoper == OPvar && type_isvla(t))
                 {
                     // It already is a pointer, so just change the type
                     type_settype(&e->ET, newpointer(t->Tnext));
                 }
                 else if (CPP || !(e->PEFflags & PEFnotlvalue))  // ANSI 
C 3.2.2
                 {   type *tp = type_ptr(e,t->Tnext);

                     tp->Talternate = t;
                     t->Tcount++;
                     e = el_unat(OPaddr,tp,e);
                 }
                 break;
#if TX86
             case TYnfunc:
             case TYnpfunc:
             case TYnsfunc:
             case TYnsysfunc:
             case TYfsysfunc:
             case TYf16func:
             case TYfsfunc:
             case TYifunc:
             case TYjfunc:
#endif
             case TYffunc:
             case TYfpfunc:
                 e = exp2_addr(e);
                 break;
         }
     }
     return e;
}


More information about the Digitalmars-d-announce mailing list