comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com
Subject: Re: More C
Date: 2000/02/01
Date: 2000-02-01T00:00:00+00:00	[thread overview]
Message-ID: <w7vl4.105$uR3.9291@nnrp1-w.snfc21.pbi.net> (raw)
In-Reply-To: vhioga1r2j8.fsf@grotte.ifi.uio.no

>What if the compiler decides to optimize access to the record,
>so the real memory structure becomes as follows?
  If you give a record representation clause it can't.  Without
the rep' clause, yes, and there are compilers that would optimize
by putting things at double word boundaries or whatever.  That's
the whole reason for rep clauses - when the memory layout really,
truly, has to be a certain way.

>it's not going to replace the original one dimentional buffer, since
>you then would have to know the dimentions, or at least a set of possible
>dimentions, in advance.  But you could as example read the dimentions
>from the command line or from an image file.
  A long time ago I made a VESA graphic interface.  At initialization
it asked the hardware what resolution modes were available, found
the best (criterion supplied by the application program), and defined
  subtype X_Range is Integer range 0 .. X_Res;
  subtype Y_Range is Integer range 0 .. Y_Res;
which could then be used for
  Image : array(Y_Range, X_Range) of Pixels;
It's certainly no less efficient to have the compiler generate
code to multiply the Y coordinate by the row size and add the
X coordinate, vs having the user do it explicitly and visibly.
It may even be more efficient.  It's also a lot less likely to
have a mistake.




  parent reply	other threads:[~2000-02-01  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <vhizotrc4x7.fsf@grotte.ifi.uio.no>
2000-01-28  0:00 ` More C tmoran
2000-01-28  0:00   ` David Starner
2000-01-28  0:00     ` Pascal Obry
2000-01-28  0:00       ` David Starner
2000-01-28  0:00         ` tmoran
2000-01-28  0:00 ` Jeff Carter
2000-01-28  0:00 ` Gautier
2000-01-30  0:00 ` Nick Roberts
     [not found]   ` <vhioga1r2j8.fsf@grotte.ifi.uio.no>
2000-02-01  0:00     ` tmoran [this message]
2000-02-02  0:00     ` Nick Roberts
2000-02-03  0:00     ` Keith Thompson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox