osargs functions and 32 bit values
Tony van der Hoff
OSLib at mk-net.demon.co.uk
Tue Aug 22 09:44:45 BST 2000
On Mon, 21 Aug 2000, at 17:35:10, Jonathan Coxhead
<jonathan at doves.demon.co.uk> wrote on the subject "osargs functions and
32 bit values":
> On 1 Aug 00, at 21:53, David J. Ruck wrote:
>
> | Shouldn't all the OS_Args file pointer and extent calls use unsigned
>types,
> | bits rather than int ?
>
> Though you could get an extra bit by doing that, I don't like it. Bjarne
>Stroustrup also offers the advice that "gaining an extra bit by using
>unsigned types is rarely a good idea" (I paraphrase.)
>
> The reason is that it can introduce obscure errors. It's bad enough that
>
> if (strlen (s) > 1)
>
>is different from
>
> if (strlen (s) - 1 > 0)
>
>(the first does what you think, the second can never fail) without
>compounding the problem further.
>
> My rule of thumb is, if a quantity is only subject to bitwise operators
>(| & ~ ^) then it is declared |bits|; if it may also be used with
>arithmetic operators (+ - * / << >>) then it is declared |int|, even if it
>so happens that it will only take positive values.
>
> Obviously, this is a matter of taste, and that's mine :-).
>
In theory, I'd agree with what you're saying.
However, one has to be pragmatic. It may not be 'a good idea', but we
can only reflect what is imposed by RISC OS. File extents do appear to
be 32 bit, even if FileCore doesn't support that.
If a 4Gb filing system were to emerge, before a new FileCore, and we
chose to support it, then I think we'd be forced to add the extra
functions. As it stands, in accordance with government guidelines, we'll
adopt a wait-and-see policy ;-)
--
Tony van der Hoff | Mailto:tony at mk-net.demon.co.uk
| Mailto:avanderhoff at iee.org
Buckinghamshire, England | http:www.mk-net.demon.co.uk
More information about the oslib-user
mailing list