comp.lang.ada
 help / color / mirror / Atom feed
From: Optikos <ZUERCHER_Andreas@outlook.com>
Subject: Re: Creating several types from a base type and conversion
Date: Fri, 24 Jan 2020 04:38:51 -0800 (PST)
Date: 2020-01-24T04:38:51-08:00	[thread overview]
Message-ID: <3eddd281-9d67-48c2-9cd4-5ad220444c0c@googlegroups.com> (raw)
In-Reply-To: <4878f44b-9f82-45d0-86eb-a63894a2c5bf@googlegroups.com>

On Friday, January 24, 2020 at 3:35:04 AM UTC-6, Ken Roberts wrote:
> On Thursday, January 23, 2020 at 1:39:13 PM UTC-8, Optikos wrote:
> 
> <snip>
> 
> > Instead of depending on a big-language solution of a very-feature-rich compiler, there is a common industrial practice in both Ada and other languages that I mentioned in my 2 replies:  use 2 different packages with same-named identifiers (especially functions or procedures) to link in either the little-endian implementation or big-endian implementation (or any other nonportability that is peculiar to a target ISA or target OS).  This solution is at the heart of VIPER and MVVM software architectures for taming the portability beast quite well (going so far as to tame even radical philosophical departures among the very divergent GUIs/window-managers:  Gnome/GTK, Windows UWP, Win32, KDE/Qt, Tizen).
> 
> <snip>
> 
> It was my understanding that big/little-endian representations were mainly how data was accessed from memory that used 8-bit bytes for physical memory layout.
> 
> Using a 16-bit register as an example:
> 
> register: [first byte][second byte]
> 
> In big-endian format the memory usage would be:
> 
> adx 0: [first byte]
> adx 1: [second byte]
> adx 2: [first byte]
> adx 3: [second byte]
> 
> In little-endian format the memory usage would be:
> 
> adx 0: [second byte]
> adx 1: [first byte]
> adx 2: [second byte]
> adx 3: [first byte]
> 
> Is my understanding off?

Yes, you are correct sort of, depending on how you define “first” and “second”.  If first is low-valued powers of 2 increasing ascendingly up to 16 (or 32), then you have it backwards.  If first is high-valued powers of 2 decreasing descendingly down to 0, then you have it correct.  As AdaMagica also nudged in the better-thinking direction, the terms most-significant byte and least-significant byte and most-significant (16-bit-)word and least-significant word are clearer thinking because they overtly refer to the powers of 2 mathematically.  Ada's bit_order refers to whether the ISA refers to the bits (independent of the bytes and words) in power-of-2 order mathematically where 2⁰ is the origin and usually called bit zero (instead of bit one) or opposite of power-of-2 order anti-mathematically/lexicaly where 2¹⁶ is the origin often called bit one (or more rarely bit zero) in 16-bit words and where 2³² is the origin often called bit one (or more rarely bit zero) in 32-bit words.

But I am focusing on a different debate.  Should a) an all-knowing omniscient compiler feature be the basis of your portability, deferring the responsibility to the language, or b) overt source code that you write in a structured way be the basis of your portability, taking the responsibility on yourself?  The omnsiscent compiler feature needs to present in all compilers across all targets and nonbuggy (or bug-for-bug compatibility) across all targets, whereas the overt source code architecture depends only on having a way to substitute one Ada package for another with same-named identifiers on this target versus that target.  In the overt source-code architecture there are little-endian versions of certain functions (or procedures) and big-endian versions of those same-named functions (or procedures).  Indeed, the this versus that package switcheroo at build-time can be utilized for more portability challenges than mere endianness, but also for this OS versus that OS (e.g., POSIX versus Windows) and this GUI framework versus that GUI framework (e.g., Gnome/Gtk versus Windows UWP versus Win32 versus Carbon versus Cocoa versus CocoaTouch versus Tizen) all of which is far far far beyond the capabilities of any omniscient compiler to hide.  VIPER takes this build-time switcheroo to the Nth degree (but you might not need all of VIPER); MVVM less so than VIPER, but both as a valid stern criticism of MVC's excessive interconnectedness that causes MVC to ruin this degree of portability.  All 3 of VIPER, MVVM, and MVC is a criticism of the omniscient compiler feature trying to accomplish the portability for you intrinsically behind the scenes.


  parent reply	other threads:[~2020-01-24 12:38 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-18  7:32 Creating several types from a base type and conversion Ken Roberts
2020-01-18 12:16 ` Simon Wright
2020-01-18 12:49   ` Ken Roberts
2020-01-18 14:56     ` Bill Findlay
2020-01-18 16:13       ` Jeffrey R. Carter
2020-01-18 18:20         ` Bill Findlay
2020-01-18 18:32           ` Jeffrey R. Carter
2020-01-18 20:34             ` Simon Wright
2020-01-20 16:38               ` Bill Findlay
2020-01-18 22:20       ` Ken Roberts
2020-01-18 15:09     ` Simon Wright
2020-01-18 22:16       ` Ken Roberts
2020-01-18 22:35         ` Simon Wright
2020-01-18 23:03           ` Ken Roberts
2020-01-18 23:38             ` Simon Wright
2020-01-19  0:12               ` Ken Roberts
2020-01-19  9:37                 ` Simon Wright
2020-01-19 11:48                   ` AdaMagica
2020-01-19 14:51                     ` Simon Wright
2020-01-19 15:24                       ` Niklas Holsti
2020-01-19 16:11                     ` Optikos
2020-01-19  0:33               ` Ken Roberts
2020-01-19  0:07         ` Niklas Holsti
2020-01-18 15:47     ` Simon Wright
2020-01-21 21:35     ` Shark8
2020-01-21 23:06       ` Niklas Holsti
2020-01-22  1:08         ` Ken Roberts
2020-01-22 14:18           ` Ken Roberts
2020-01-22  8:37       ` Simon Wright
2020-01-22 14:32         ` Shark8
2020-01-22 15:40           ` Simon Wright
2020-01-18 14:17   ` Optikos
2020-01-18 17:57 ` Niklas Holsti
2020-01-18 22:59   ` Ken Roberts
2020-01-19  0:30     ` Niklas Holsti
2020-01-19  1:07       ` Ken Roberts
2020-01-19  3:37 ` Ken Roberts
2020-01-23 21:39 ` Optikos
2020-01-24  9:35   ` Ken Roberts
2020-01-24 10:04     ` AdaMagica
2020-01-24 12:38     ` Optikos [this message]
2020-01-24 15:01       ` Ken Roberts
2020-01-24 15:22         ` Simon Wright
2020-01-24 15:40           ` Ken Roberts
2020-01-24 15:54   ` Simon Wright
2020-01-25 10:37 ` Ken Roberts
2020-01-25 10:44   ` Ken Roberts
2020-01-25 20:26   ` Shark8
2020-01-27 14:10 ` Ken Roberts
replies disabled

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