POV-Ray : Newsgroups : povray.off-topic : Haskell raving : Re: Haskell raving Server Time
11 Oct 2024 15:18:25 EDT (-0400)
  Re: Haskell raving  
From: Darren New
Date: 4 Nov 2007 12:34:53
Message: <472e02bd$1@news.povray.org>
Orchid XP v7 wrote:
> Darren New wrote:
>> Invisible wrote:
>>> (and AFAIK in plain C) you *must* expose all implementation details 
>>> of a type in order for anybody else to be able to touch it. 
>>
>> Nah. Just use a forward-declared struct and pass pointers to it. You 
>> know, like fopen/fread/fwrite/fclose.  Note those haven't changed 
>> since the first edition of K&R.
> 
> I have no concept of what you're talking about - but you're probably 
> right...

In C, you declare a pointer to a structure without defining the layout 
of the structure. C allows this, because it assumes all pointers are the 
same size and have a unified alignment requirement and can all live in 
the same kinds of registers and things like that.

Then in your code file, you define the structure. Creating an object 
involves allocating the structure and returning the opaque pointer to 
it. Using the object requires passing the opaque pointer back in.

No implementation details are visible at all.

http://en.wikipedia.org/wiki/C_file_input/output

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.