comp.lang.ada
 help / color / mirror / Atom feed
From: Lucretia <laguest9000@googlemail.com>
Subject: Re: Why can't objects be static in Ada?
Date: Thu, 11 Apr 2019 18:56:02 -0700 (PDT)
Date: 2019-04-11T18:56:02-07:00	[thread overview]
Message-ID: <322de0e0-9b7c-478f-be70-4d0f88c74d6d@googlegroups.com> (raw)
In-Reply-To: <q8og92$1u7$1@franka.jacob-sparre.dk>

On Thursday, 11 April 2019 23:49:07 UTC+1, Randy Brukardt  wrote:
> "Lucretia" <> wrote in message 
> news:b411a770-5e86-4d5e-9e43-e52843be724d@googlegroups.com...
> > Someone sent in a pull request to my bindings and had to change a few
> >constants to functions because objects can't be static.
> 
> This is nonsense:

What bollocks.

>      Max : constant Integer := 10;
> 
> is an object, and it's static.

I'm not talking about primitive types, I even pointed it out with an actual example. Oh look, there it is...
 
> >For an example:
> >
> >   type Sizes is
> >      record
> >         Width  : Dimension;
> >         Height : Dimension;
> >      end record with
> >     Convention => C;
> 
> This is a composite type. Only numeric types and strings (and the latter is 
> a hack) can be static.

I couldn't care less if it's composite, the language should dictate that something this simple with expressed initial values should be static.

> >   Zero_Size : constant Sizes := (others => Natural_Dimension'First);
> >
> > Why can't Zero_Size be compiled as static in this pre-elaborated package?
> 
> Because composite types are never static. A compiler that treated it as 
> "static" would be wrong. OTOH, that doesn't prevent a compiler from 
> evaluating it at compile-time.

Well, that's wrong and the language should allow composite types, if they can have initial values defined and when constant should be static. It's not hard tp grasp.
 
> And the categorization pragmas are an area where the original scheme was a 
> failure. The idea that the properties of every operation of a type can all 
> have the same restrictions is maddening. Hopefully, the Global aspect will 
> fix this. There's no good reason (outside of Annex E issues) for declaring 

I don't know what the global aspect is but I doubt it'll fix this issue.

> any package preelaborated, unless you like fighting errors a lot. C.4 is a 
> load of hooey, it's not actually implementable on the margins, and there's 
> no reason for any compiler to generate more code than necessary. Ergo, 
> you'll most likely get the same code whether or not you declare something 
> Preelaborated, so why bother with all of the hassles?
> 
> > This seems to be a major flaw in Ada imo.
> 
> "Preelaborated packages" are a minor flaw of Ada, but you never have to use 
> them. And if you don't, the rest of it is irrelevant. So I see no "major 
> flaw".

Wrong, if something can be compiled to be static so that there's no elaboration code, then that's a good thing, why execute anything at runtime if there's no need. Seems you are stuck in backward land where everything should be initialised with code, get a grip and drag your arse into the 21st century!

> That said, I would have preferred allowing the declaration of user-defined 
> static types, because it is annoying to write representation clauses as it 
> stands. (Since X'Size is only static for numeric types, it's nearly useless 
> in representation aspects. Which makes them more complex than necessary. But 
> at worst, that is an annoyance.) It was deemed too complicated for too 
> little benefit this time around. Feel free to bring it up again if you still 
> care and don't mind waiting another 5+ years.

Yeah well, I haven't got another 5+ years to waste waiting for you lot to catch up.


  reply	other threads:[~2019-04-12  1:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 12:40 Why can't objects be static in Ada? Lucretia
2019-04-11 12:56 ` Mark Lorenzen
2019-04-11 13:31   ` Lucretia
2019-04-11 22:49 ` Randy Brukardt
2019-04-12  1:56   ` Lucretia [this message]
2019-04-12  7:33     ` Dmitry A. Kazakov
2019-04-12 22:38     ` Randy Brukardt
2019-04-13  9:14       ` Lucretia
2019-04-12  6:59   ` Mark Lorenzen
2019-04-12  8:12     ` Simon Wright
2019-04-12 22:02     ` Randy Brukardt
2019-04-13 13:07 ` Jere
2019-04-13 13:48   ` Lucretia
2019-04-15 17:46     ` G. B.
2019-04-14  3:47 ` Keith Thompson
2019-04-16  0:08 ` sbelmont700
2019-04-16  1:40   ` Randy Brukardt
2019-04-16 12:11     ` Mark Lorenzen
2019-04-16 16:19       ` Simon Wright
2019-04-16 20:56       ` Lucretia
2019-04-16 21:07         ` Niklas Holsti
2019-04-16 21:16           ` Lucretia
2019-04-16 21:40             ` Niklas Holsti
2019-04-16 23:26             ` Randy Brukardt
2019-04-23 14:30           ` Mark Lorenzen
2019-04-16 23:09       ` Randy Brukardt
2019-04-22 20:05       ` Norman Worth
2019-04-16 20:54     ` Lucretia
2019-04-16 23:15       ` Randy Brukardt
2019-04-16 20:53   ` Lucretia
2019-04-18 13:32 ` sbelmont700
replies disabled

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