🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #4414

Re: Size of enumerations/subranges in Modula-2

#4414
From: Rick Pelleg
Date: Mon, 29 Aug 1988 18:01
67 lines
3056 bytes
Here is a summary of the responses received so far to my question on the net,
regarding the size of enumeration and subrange types in Modula-2.

I repeat the main points in my question at the end of this summary.

###############################################################################

Stuart Lomas (sjl%myrias)
(Compilers Group; Myrias Research Corporation; Edmonton, Alberta, Canada)
	If the time overhead is fairly small, use smallest amount of space.

	Best solution:  Pick a default; allow user to override with compiler
	option.  Default should be the fastest option.

ken%cs.rochester:
	Make them full ints.  The saving in pack/unpack code makes up for
	space wastage.

Mick Jordan (mjj%acornrc):
	Many Modula-2 compilers implement enumerated types, subranges and
	booleans in one word, to avoid packing or using byte instructions.

	Would optimise for speed against space these days.

	The real pain in not having byte-sized quantities is in the interface
	to C.

R. Tim Coslet (R_Tim_Coslet%cup.portal):
	Consider compiler options.

Christopher Jewell (chrisj%cup.portal):
	Subranges usually occupy the same storage as the base type, but enums
	often occupy the minimum space required.  Enumerations are often
	restricted to 256 elements.

Pete Soper (soper%maxzilla - Encore Computer Corp):
	The 32k version of the ETH compiler - 1 byte for any enumeration, 4
	bytes for integer/cardinal subranges.

	Except for memory tight environments or interface with other languages,
	allocate 4 bytes for every scalar type.  Note that alignment causes
	waste of bytes anyway.

Jeff Woolsey (woolsey%nsc)
	Would like to see enumerations implemented in minimum space.  32 bits
	is OVERKILL for enumerations.

###############################################################################

My question was:

> One problematic implementation issue in our NS32000 Modula2 compiler is that
> of the size of enumeration types and subrange types:
>  1. An enumeration/subrange occupies the least possible amount of bytes (the
>     NS32000 are byte addressable machines).
>  2. An enumeration/subrange always occupies four bytes (a double-word).  This
>     is the "natural" size on the NS32000.
>Any opinions about this issue?  In particular, I am interested in the
>following two questions:
>  1. How do Modula-2 compilers you know implement enumerated types and
>     subranges?
>  2. How would you like to see them implemented?
-- 
--- Rick Pelleg
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel  Tel. (972)52-522264
rick%taux01@nsc.com @{hplabs,pyramid,sun,decwrl}
Technical Details
Message-ID: <109@taux02.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!gatech!ncar!ames!amdahl!nsc!taux01!taux02!rick

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!gatech!ncar!ames!amdahl!nsc!taux01!taux02!rick
From: rick@taux02.UUCP (Rick Pelleg )
Newsgroups: comp.lang.modula2
Subject: Re: Size of enumerations/subranges in Modula-2
Message-ID: <109@taux02.UUCP>
Date: 29 Aug 88 18:01:20 GMT
Organization: National Semiconductor (IC) Ltd, Israel
Lines: 67