www.digitalmars.com         C & C++   DMDScript  

D - Abstraction for primitive types?

reply Helmut Leitner <helmut.leitner chello.at> writes:
Is there an abstraction planned for primitive types?

Something that would allow to write generic interfaces like

   TypeToUnistring(type t) {
      TypeInfo *pti=t.info;
      char buf[40];
      int n=(*pti.toMem)(&t,buf);       
      return MemRetUnistring(buf,n);
   }

or

   void ArrayRandomize(type [] ar) {
      ....
      algorithm using swap from typeinfo
      ....
   }

?

--
Helmut Leitner    leitner hls.via.at   
Graz, Austria   www.hls-software.com
Apr 21 2003
parent reply "Walter" <walter digitalmars.com> writes:
The t.info should work now.

"Helmut Leitner" <helmut.leitner chello.at> wrote in message
news:3EA3B257.6974D98D chello.at...
 Is there an abstraction planned for primitive types?

 Something that would allow to write generic interfaces like

    TypeToUnistring(type t) {
       TypeInfo *pti=t.info;
       char buf[40];
       int n=(*pti.toMem)(&t,buf);
       return MemRetUnistring(buf,n);
    }

 or

    void ArrayRandomize(type [] ar) {
       ....
       algorithm using swap from typeinfo
       ....
    }

 ?

 --
 Helmut Leitner    leitner hls.via.at
 Graz, Austria   www.hls-software.com
Apr 24 2003
parent reply Helmut Leitner <helmut.leitner chello.at> writes:
Walter wrote:
 
 The t.info should work now.
What means "now"? In the next version DMD 0.62?
 "Helmut Leitner" <helmut.leitner chello.at> wrote in message
 news:3EA3B257.6974D98D chello.at...
 Is there an abstraction planned for primitive types?

 Something that would allow to write generic interfaces like

    TypeToUnistring(type t) {
       TypeInfo *pti=t.info;
       char buf[40];
       int n=(*pti.toMem)(&t,buf);
       return MemRetUnistring(buf,n);
    }

 or

    void ArrayRandomize(type [] ar) {
       ....
       algorithm using swap from typeinfo
       ....
    }

 ?

 --
 Helmut Leitner    leitner hls.via.at
 Graz, Austria   www.hls-software.com
-- Helmut Leitner leitner hls.via.at Graz, Austria www.hls-software.com
Apr 24 2003
parent "Walter" <walter digitalmars.com> writes:
"Helmut Leitner" <helmut.leitner chello.at> wrote in message
news:3EA8443F.165D429E chello.at...
 Walter wrote:
 The t.info should work now.
What means "now"? In the next version DMD 0.62?
Yes, unless I goofed it up <g>.
Apr 24 2003