What it the preferred method to write a class to a file?
Regan Heath
regan at netwin.co.nz
Sun Jul 23 17:54:20 PDT 2006
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
>> 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.)
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
More information about the Digitalmars-d-learn
mailing list