Subj : HW 100.2
To   : Prime
From : Amcleod
Date : Mon Dec 10 2001 07:28 am

RE: HW 100.2
BY: Prime to Amcleod on Sat Dec 08 2001 02:20 pm

> Just a thought, but shouldn't there be some mechinism to prevent the acciden
> adding of file handles?

Well, that would require the declaration of a new basic type, so that the
compiler could distinguish between handles and integers and prevent certain
operatyions on handles that itn otherwise allows on integers.

There are different file I/O models that don't use file handles per se.  You
could use some sort of stream-based I/O like the C/C++ fopen() mechanism that
opens a stream and returns a pointer to a file-object.

But there are _occasionally_ reasons that might cause you to legitimately do
arithmetic to a file handle.  Say you wanted to open six files and send data to
each of them in turn in a round-robin scheme (for whatever reason).  Then
*_IF_* your file handles are simple numeric integers, you could do something
that outputs to the handle and adds one to it (to point to the next file) so
that each output went to the next file.  You would have to check that you were
at file #6 and reset to #1, but in theory you could do handle-arithmetic.  Not
a wise move, though, unless you are very intimate with the internal workings of
your compiler and your OS.  Dangerous and non-portable.  Microsoftian, even!

---
� Synchronet � Vertrauen � Home of Synchronet � telnet://vert.synchro.net