[M3devel] M3CG

Jay K jay.krell at cornell.edu
Tue Sep 4 22:47:05 CEST 2012


RECORD HoldsTypeUID:
  typeuid: [FIRST(TypeUID)..LAST(TypeUID)];
END?
 But what if I'm really just a holder/passer of this thing,
and I never interpret it. Now TypeUID can't be changed
to LONGREAL or somesuch. Ideally some code wouldn't care
and still be correct.
 The idea is to hold the thing, pass it on, without knowing
what it is. I want a field with the same type.
 Why does it matter if TypeUID is representable in 32 bits?
Isn't the range the interface?
If it wasn't for readability of all the F's, I think
TypeUID = [-16_7FFFFFFF - 1 .. 16_7FFFFFFF]; is best. 
Do we really care about few or many bits that occupies? 
Cstdint.int32_t I agree is a bit lazy.
Maybe something like Word.Shift(1, 31) .. Word.Not(Word.Shift(1, 31)) ?
A bit wordy but ok.Maybe not correct. Not clear the start is negative.Maybe needs to be more like: (-Word.Not(Word.Shift(1, 31))) - 1 .. Word.Not(Word.Shift(1, 31))   But these bit twiddlings might then confuse people.So maybe having to count F's is better.. :(  You know, what about being 32bits in size would be part of an interface?
I don't think much/anything, but maybe. 
Do we do/allow things like bit operations on it? Index into it a certain number
of bits? Take the address and assume BYTESIZE == 4?
I could see those maybe occuring. Maybe.
 But I'm pretty sure they values are fairly abstract/opaque and the best anyone can do
is format them as strings and compare them for e.g. sorting purposes, but must
assume they are fairly sparse.  Btw, whenever the matter of "portability to signed-magnitude" or one's complement
comes up, I admit I get a bit confused. Two's complement is very ingrained
in my world view.  I agree TInt.T suffices.
Just like CARDINAL isn't needed, INTEGER suffices.
Cardinal.T just disallows negative numbers earlier, or at lower level, etc.
If we had to use TInt.T and add checks in a few places that it >= 0, ok.
It seems a little nice to put the checking in.   - Jay



 > Subject: Re: M3CG
> From: hosking at cs.purdue.edu
> Date: Tue, 4 Sep 2012 13:05:34 -0400
> CC: m3devel at elegosoft.com
> To: jay.krell at cornell.edu
> 
> On Sep 4, 2012, at 12:09 PM, Jay <jay.krell at cornell.edu> wrote:
> 
> > "BITS" seems to not provide any useful value. It only makes it so you can't put the type into a portable unpacked record, which is what I was doing. I either have to pack my record somehow (counting target-dependent bits??) or lay out the fields carefully in some way that all targets allow. The problem was that some targets didn't like the layout.
> 
> For M3CG.TypeUID the BITS 32 enforces that it is always representable in 32 bits.   This is a fundamental invariant of the compiler and run-time system.  Removing it might allow bug creep.  You don’t need to pack your record.  You just need a field sufficiently large to hold the value of a type id.  In this instance an INTEGER field would suffice, or you can use the same subrange.
> 
> > Given the stated range, that you'll get enough bits to store it, what is the point in giving the size too? Isn't providing just the range and no particular size, sufficient & more abstract? Granted, I went the other way.
> 
> Only if an implementation chooses to store a subrange in as few bits as necessary.  Yes, CM3 does this, but it is not guaranteed by the language spec.  Here the size is the critical invariant.
> 
> > I don't remember but guessing:
> > 
> > 
> > Cardinal.T would be, like CARDINAL vs. INTEGER: only slightly subtley useful: same as TInt.T, but disallows negative numbers.
> 
> But for what purpose.  The target does not have CARDINAL.  It only has a target integer.
> 
> > Most likely I ran into places where a host integer/cardinal did not necessarily suffice, and so a target type was called for.
> > 
> > 
> > I know we have places that need to  use target types but don't yet. Specifically for the sizes of things like records & arrays. Otherwise we have hacks where 64bit systems declare 32bit limits.
> 
> Again, TInt.T suffices for all of these.
> 
> > 
> > 
> > - Jay (briefly/pocket-sized-computer-aka-phone)
> > 
> > On Sep 4, 2012, at 7:11 AM, Antony Hosking <hosking at cs.purdue.edu> wrote:
> > 
> >> Jay,
> >> 
> >> I’ve been looking over some of your changes to M3CG interfaces.  You’ll notice that I removed your import of Cstdlib.int into M3CG_Ops.i3.  It does not belong there.  The type as declared:
> >> 
> >> TypeUID = BITS 32 FOR [-16_7fffffff-1 .. 16_7fffffff];
> >> 
> >> is correct as is.  It is a 32 bit value that encodes a particular subrange, REGARDLESS of target machine.  It is improper to change that definition to rely on some C type.
> >> 
> >> I also have some other questions.  Why did you add the type Cardinal.T?  This seems entirely unnecessary, since targets don’t have a Cardinal type.  The only type they have is a target integer.  All other Modula-3 ordinal types should be simulated in the compiler using TInt.T.  I would advise that it be removed.  Also, I don’t understand why you changed descriptions of the primitive types to use this Cardinal.T instead of the original CARDINAL to hold information about the bit size, alignment, and byte size.  There is no situation in which a host will need to emulate the behavior of CARDINAL for these values (all can be represented using CARDINAL no matter what the host).
> >> 
> >> I am concerned that these changes reflect a desire on your part to change the world to fit your specific needs (whether justified or not).  The interfaces defined in M3CG were carefully designed and inherit from a long code-chain going back to the 1980’s and have not see huge changes since then.  I strongly advise against making changes unless you have good reason, because there are a number of tools that rely on M3CG (not just those in the public sources).
> >> 
> >> I am going to do a pass to revert some of your changes, since they are causing a number of my systems to fail to build.  (cf. Niagara on tinderbox).
> >> 
> >> I strongly advise that you try to use a private branch when developing new functionality.  We as a community can then go through a revision process to vet substantive changes before merging them into the trunk.
> >> 
> >> — Tony
> >> 
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120904/aa35557b/attachment-0002.html>


More information about the M3devel mailing list