🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #3206

Re: Modula2 for C programmers?

#3206
From: Martin Tom Brown
Date: Mon, 29 Jan 1996 09:33
46 lines
2437 bytes
In article <4eh2d6$18d@seagoon.newcastle.edu.au>
           peter@tesla.newcastle.edu.au "Peter Moylan" writes:

> When I first came to Modula-2 I used BITSET for things like
> manipulating I/O ports; I imagine that Wirth had things like that
> in mind when he put BITSET into the language.

Wasn't it intended simply as a packed array of BOOLEAN  
from the bad old days when ram was expensive and in short supply?

> 2. Bit numbering: is bit 0 the leftmost bit, or the rightmost?
>    People have been arguing over which of these two conventions
>    is "best" for years, and neither camp has dominated

The irresistable force meets the immovable object.

> The ISO M2 standard does, I think, dictate a little-endian
> ordering for BITSET.  (That's from memory; I've forgotten which
> section I should look up.)  But that doesn't completely resolve
> the problems that arise when, for example, you upgrade your
> PC compiler from 16-bit to 32-bit support.

Oh dear! 
I supose that is the purist solution. Define it arbitrarily. 

I had hoped that a definition of bit number might have been
based on the system hardware architecture features so that the 
	n th bit of a BITSET is always the 2^n bit in a CARDINAL
This would be a VAL type conversion (rather than coercion).
This is at least as natural and logical as defining the 
REAL <> INTEGER, CARDINAL casts

An interesting diversion is that if the definition is as you describe
then there is scope for confusion in the future if both are allowed:
since	CAST(BITSET, x) <> VAL(BITSET, x) 	on some systems.
I suppose you get round this by not allowing VAL(BITSET,x).

> I remain convinced that BITSET should have been defined in
> SYSTEM, so that it was clearly labelled as non-portable.

Seconded.

Regards,
-- 
Martin Brown  <martin@nezumi.demon.co.uk>     __                CIS: 71651,470
Scientific Software Consultancy             /^,,)__/
Technical Details
Message-ID: <822907984snz@nezumi.demon.co.uk>
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!nezumi.demon.co.uk
References: <4eh2d6$18d@seagoon.newcastle.edu.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!nezumi.demon.co.uk
From: Martin Tom Brown <Martin@nezumi.demon.co.uk>
Newsgroups: comp.lang.modula2
Subject: Re: Modula2 for C programmers?
Date: Mon, 29 Jan 96 09:33:04 GMT
Organization: Nezumi
Message-ID: <822907984snz@nezumi.demon.co.uk>
References: <4eh2d6$18d@seagoon.newcastle.edu.au>
Reply-To: Martin@nezumi.demon.co.uk
X-NNTP-Posting-Host: nezumi.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.29
X-Mail2News-Path: nezumi.demon.co.uk