What it the preferred method to write a class to a file?

Charles D Hixson charleshixsn at earthlink.net
Sun Jul 23 17:26:57 PDT 2006


Jarrett Billingsley wrote:
> "Charles D Hixson" <charleshixsn at earthlink.net> wrote in message 
> news:ea0rll$5h9$1 at digitaldaemon.com...
> 
>> P.S.:  Is there a standard library routine for converting
>> between strings of length 4 and uint-s?  If so I wasn't able
>> to find it.  If not, I wasn't able to determine that it
>> didn't exist.  (That would have made writing the sig more
>> efficient.)
> 
> You don't even need a routine to do it.
> 
> char[] sig = "help";
> uint s = *cast(uint*)sig.ptr;
> 
> And the other way..
> 
> uint s = 0xAABBCCDD;
> char[] sig = new char[4];
> *cast(uint*)sig.ptr = s; 
> 
> 
O, dear.  Yes, I see it.
But one of the things that cause me to prefer D over C is
the ability to avoid pointer manipulation, which to me seem
extremely hazardous and, when one gets beyond simple cases,
quite confusing.  (And unmaintainable.)



More information about the Digitalmars-d-learn mailing list