From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:7614:: with SMTP id g20mr3150906iom.14.1555034162987; Thu, 11 Apr 2019 18:56:02 -0700 (PDT) X-Received: by 2002:a05:6830:1192:: with SMTP id u18mr35060673otq.295.1555034162632; Thu, 11 Apr 2019 18:56:02 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.166.216.MISMATCH!136no41591itk.0!news-out.google.com!r82ni59ita.0!nntp.google.com!136no41584itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 11 Apr 2019 18:56:02 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5; posting-account=L2-UcQkAAAAfd_BqbeNHs3XeM0jTXloS NNTP-Posting-Host: 2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <322de0e0-9b7c-478f-be70-4d0f88c74d6d@googlegroups.com> Subject: Re: Why can't objects be static in Ada? From: Lucretia Injection-Date: Fri, 12 Apr 2019 01:56:02 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:56117 Date: 2019-04-11T18:56:02-07:00 List-Id: On Thursday, 11 April 2019 23:49:07 UTC+1, Randy Brukardt wrote: > "Lucretia" <> wrote in message=20 > 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. >=20 > This is nonsense: What bollocks. > Max : constant Integer :=3D 10; >=20 > 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... =20 > >For an example: > > > > type Sizes is > > record > > Width : Dimension; > > Height : Dimension; > > end record with > > Convention =3D> C; >=20 > This is a composite type. Only numeric types and strings (and the latter = is=20 > a hack) can be static. I couldn't care less if it's composite, the language should dictate that so= mething this simple with expressed initial values should be static. > > Zero_Size : constant Sizes :=3D (others =3D> Natural_Dimension'First)= ; > > > > Why can't Zero_Size be compiled as static in this pre-elaborated packag= e? >=20 > Because composite types are never static. A compiler that treated it as= =20 > "static" would be wrong. OTOH, that doesn't prevent a compiler from=20 > evaluating it at compile-time. Well, that's wrong and the language should allow composite types, if they c= an have initial values defined and when constant should be static. It's not= hard tp grasp. =20 > And the categorization pragmas are an area where the original scheme was = a=20 > failure. The idea that the properties of every operation of a type can al= l=20 > have the same restrictions is maddening. Hopefully, the Global aspect wil= l=20 > fix this. There's no good reason (outside of Annex E issues) for declarin= g=20 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=20 > load of hooey, it's not actually implementable on the margins, and there'= s=20 > no reason for any compiler to generate more code than necessary. Ergo,=20 > you'll most likely get the same code whether or not you declare something= =20 > Preelaborated, so why bother with all of the hassles? >=20 > > This seems to be a major flaw in Ada imo. >=20 > "Preelaborated packages" are a minor flaw of Ada, but you never have to u= se=20 > them. And if you don't, the rest of it is irrelevant. So I see no "major= =20 > flaw". Wrong, if something can be compiled to be static so that there's no elabora= tion code, then that's a good thing, why execute anything at runtime if the= re'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 centu= ry! > That said, I would have preferred allowing the declaration of user-define= d=20 > static types, because it is annoying to write representation clauses as i= t=20 > stands. (Since X'Size is only static for numeric types, it's nearly usele= ss=20 > in representation aspects. Which makes them more complex than necessary. = But=20 > at worst, that is an annoyance.) It was deemed too complicated for too=20 > little benefit this time around. Feel free to bring it up again if you st= ill=20 > 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 c= atch up.