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

Charles D Hixson charleshixsn at earthlink.net
Mon Jul 24 13:32:50 PDT 2006


Regan Heath wrote:
> On Sun, 23 Jul 2006 17:26:57 -0700, Charles D Hixson
> <charleshixsn at earthlink.net> wrote:
>> Jarrett Billingsley wrote:
>>> "Charles D Hixson" <charleshixsn at earthlink.net> wrote in message
>>>> ...
>>>
>>> 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.)
> 
> If it works, then I say put it in a function and ignore 'how' it works.
> More than likely it will be inlined and you'll never need to worry about
> it again.
> 
> Regan
Right you are.  That's what I did...though it's a tiny bit
ugly because D won't allow functions to return char[4] and
won't allow them as out parameters.  (So I had to make it a
char[], and that worked.)



More information about the Digitalmars-d-learn mailing list