Is it possible to write a wrapper for file handles, that is
immutable if we don't plan to swap out the handle and the ref
count is in some external data structure and only accessed
in ctors/dtors of the struct ?
It would look quite a bit like some sort of head immutable,
but with no access to the mutable parts.

The motivation is that immutable is inherently shared, so it
simplifies code where a file handle might be used by several
threads but synchronization is ensured by the operating system
or at a higher level in our code.
(Otherwise one would have to reimplement read, write,
handle, ... with the exact same code, but `shared` attached or
cast away `shared`, which is wrong.)

-- 
Marco

Reply via email to