Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

A Linux machine! because a 486 is a terrible thing to waste! (By jjs@wintermute.ucr.edu, Joe Sloan)


devel / comp.lang.ada / Gnat bug or mistaken program?

SubjectAuthor
* Gnat bug or mistaken program?Richard Iswara
`* Re: Gnat bug or mistaken program?Niklas Holsti
 `* Re: Gnat bug or mistaken program?Richard Iswara
  `* Re: Gnat bug or mistaken program?Jeffrey R. Carter
   +* Re: Gnat bug or mistaken program?Shark8
   |`- Re: Gnat bug or mistaken program?Richard Iswara
   `* Re: Gnat bug or mistaken program?Niklas Holsti
    +- Re: Gnat bug or mistaken program?J-P. Rosen
    `- Re: Gnat bug or mistaken program?Randy Brukardt

1
Gnat bug or mistaken program?

<318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5596&group=comp.lang.ada#5596

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a0c:ff01:: with SMTP id w1mr30253676qvt.28.1626782523137; Tue, 20 Jul 2021 05:02:03 -0700 (PDT)
X-Received: by 2002:a25:dc50:: with SMTP id y77mr38850823ybe.405.1626782522859; Tue, 20 Jul 2021 05:02:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 20 Jul 2021 05:02:02 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=139.228.49.69; posting-account=oy9pPgoAAACICsEVtbydIrxpi9tsYOGl
NNTP-Posting-Host: 139.228.49.69
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
Subject: Gnat bug or mistaken program?
From: haujekch...@gmail.com (Richard Iswara)
Injection-Date: Tue, 20 Jul 2021 12:02:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 38
 by: Richard Iswara - Tue, 20 Jul 2021 12:02 UTC

I get this error on my program from the menu build => check semantic
exponent must be of type Natural, found type "Standard.Float".

Should not 10 ** (log10 a + log10 b) = a*b?

This is my compiler build:

GNAT Studio Community 2020 (20200427) hosted on x86_64-pc-mingw32
GNAT Community 2020 (20200429-93) targetting x86_64-pc-mingw32
SPARK Community 2020 (20200429)

Here is the relevant part of program:

with Ada.Numerics.Elementary_Functions;
use Ada.Numerics;

Counter : Integer := 1;
Logs : Float := 0.0;
Multiples : Float;

inside some loop:

Logs := Elementary_Functions.Log (Float(Counter), 10.0) + Logs;
Multiples := 10.0 ** Logs; => this is where it fails

I checked the Ada.Numerics.Generic_Elementary_Functions specifications
(since Ada.Numerics.Elementary_Functions is just an instance of the generics)
and it said:

function "**" (Left, Right : Float_Type'Base) return Float_Type'Base with
Pre => (if Left = 0.0 then Right > 0.0) and Left >= 0.0,
Post => "**"'Result >= 0.0
and then (if Right = 0.0 then "**"'Result = 1.0)
and then (if Right = 1.0 then "**"'Result = Left)
and then (if Left = 1.0 then "**"'Result = 1.0)
and then (if Left = 0.0 then "**"'Result = 0.0);

So the question is this a Gnat bug, wrong function used, faulty logic on me or
I am declaring it wrong?

Re: Gnat bug or mistaken program?

<ilo3o4F5297U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5597&group=comp.lang.ada#5597

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Tue, 20 Jul 2021 17:09:08 +0300
Organization: Tidorum Ltd
Lines: 36
Message-ID: <ilo3o4F5297U1@mid.individual.net>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net /DO46kL3iizbzx6PTphweAc1STdq9wyIknaBzhLK4+TeNiR7co
Cancel-Lock: sha1:S9MEXSDUKEXY4fr1qtzegze2daY=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.12.0
In-Reply-To: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
Content-Language: en-US
 by: Niklas Holsti - Tue, 20 Jul 2021 14:09 UTC

On 2021-07-20 15:02, Richard Iswara wrote:
> I get this error on my program from the menu build => check semantic
> exponent must be of type Natural, found type "Standard.Float".
>
> Should not 10 ** (log10 a + log10 b) = a*b?
>
> This is my compiler build:
>
> GNAT Studio Community 2020 (20200427) hosted on x86_64-pc-mingw32
> GNAT Community 2020 (20200429-93) targetting x86_64-pc-mingw32
> SPARK Community 2020 (20200429)
>
> Here is the relevant part of program:
>
> with Ada.Numerics.Elementary_Functions;
> use Ada.Numerics;

To make Ada.Numerics.Elementary_Functions."**" visible without
qualification, you should also do "use Ada.Numerics.Elementary_Functions".

Otherwise the compiler will see only the predefined operator:

function "**"(Left : Float; Right : Integer'Base) return Float

(see RM 4.5.6(9 and 10)) which explains why the compiler does not accept
a floating-point value as the Right operand to "**".

> Logs : Float := 0.0;
> Multiples : Float;
...> Multiples := 10.0 ** Logs; => this is where it fails

It fails because the compiler sees only the predefined "**" operator
which has an integral right operand.

Re: Gnat bug or mistaken program?

<b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5598&group=comp.lang.ada#5598

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!mRBVMlGoFUnDsRgMYRJiSw.user.46.165.242.75.POSTED!not-for-mail
From: haujekch...@gmail.com (Richard Iswara)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Wed, 21 Jul 2021 09:23:03 +0700
Organization: Aioe.org NNTP Server
Message-ID: <b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
<ilo3o4F5297U1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="19375"; posting-host="mRBVMlGoFUnDsRgMYRJiSw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Richard Iswara - Wed, 21 Jul 2021 02:23 UTC

On 20/07/2021 21.09, Niklas Holsti wrote:
> On 2021-07-20 15:02, Richard Iswara wrote:
>> I get this error on my program from the menu build => check semantic
>> exponent must be of type Natural, found type "Standard.Float".
>>
>> Should not 10 ** (log10 a + log10 b) = a*b?
>>
>> This is my compiler build:
>>
>> GNAT Studio Community 2020 (20200427) hosted on x86_64-pc-mingw32
>> GNAT Community 2020 (20200429-93) targetting x86_64-pc-mingw32
>> SPARK Community 2020 (20200429)
>>
>> Here is the relevant part of program:
>>
>> with Ada.Numerics.Elementary_Functions;
>> use Ada.Numerics;
>
>
> To make Ada.Numerics.Elementary_Functions."**" visible without
> qualification, you should also do "use Ada.Numerics.Elementary_Functions".
>
> Otherwise the compiler will see only the predefined operator:
>
>    function "**"(Left : Float; Right : Integer'Base) return Float
>
> (see RM 4.5.6(9 and 10)) which explains why the compiler does not accept
> a floating-point value as the Right operand to "**".
>
>
>> Logs : Float := 0.0;
>> Multiples : Float;
>    ...> Multiples := 10.0 ** Logs;  => this is where it fails
>
>
> It fails because the compiler sees only the predefined "**" operator
> which has an integral right operand.

Thank you. So it is a visibility problem.

Re: Gnat bug or mistaken program?

<sd8lsv$crp$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5599&group=comp.lang.ada#5599

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.not.acm.org (Jeffrey R. Carter)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Wed, 21 Jul 2021 10:29:18 +0200
Organization: Also freenews.netfront.net; news.tornevall.net;
news.eternal-september.org
Lines: 73
Message-ID: <sd8lsv$crp$1@dont-email.me>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
<ilo3o4F5297U1@mid.individual.net>
<b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 21 Jul 2021 08:29:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a03207487f6db667a2bda8746cfc6baf";
logging-data="13177"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+F9vQtufItJSDLY0wA87uk5K6wDtP+m7w="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:QBYIDkM8M57bw88/JY7Ebn5PoI8=
In-Reply-To: <b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com>
Content-Language: en-US
 by: Jeffrey R. Carter - Wed, 21 Jul 2021 08:29 UTC

On 7/21/21 4:23 AM, Richard Iswara wrote:
> On 20/07/2021 21.09, Niklas Holsti wrote:
>> On 2021-07-20 15:02, Richard Iswara wrote:
>>> I get this error on my program from the menu build => check semantic
>>> exponent must be of type Natural, found type "Standard.Float".
>>>
>>> Should not 10 ** (log10 a + log10 b) = a*b?
>>>
>>> This is my compiler build:
>>>
>>> GNAT Studio Community 2020 (20200427) hosted on x86_64-pc-mingw32
>>> GNAT Community 2020 (20200429-93) targetting x86_64-pc-mingw32
>>> SPARK Community 2020 (20200429)
>>>
>>> Here is the relevant part of program:
>>>
>>> with Ada.Numerics.Elementary_Functions;
>>> use Ada.Numerics;
>>
>>
>> To make Ada.Numerics.Elementary_Functions."**" visible without qualification,
>> you should also do "use Ada.Numerics.Elementary_Functions".
>>
>> Otherwise the compiler will see only the predefined operator:
>>
>>     function "**"(Left : Float; Right : Integer'Base) return Float
>>
>> (see RM 4.5.6(9 and 10)) which explains why the compiler does not accept a
>> floating-point value as the Right operand to "**".
>>
>>
>>> Logs : Float := 0.0;
>>> Multiples : Float;
>>     ...> Multiples := 10.0 ** Logs;  => this is where it fails
>>
>>
>> It fails because the compiler sees only the predefined "**" operator which has
>> an integral right operand.
>
> Thank you. So it is a visibility problem.

"Understanding visibility is the key to understanding Ada." -- /Ada Distilled/

Recommending the use package clause as a solution to a misunderstanding of
visibility is a disservice to a beginning user. Widespread application of use
pkg clauses is a crutch to avoid understanding visibility. I recommend that
those who do not understand visibility avoid the use clause altogether, as this
forces them to learn about visibility. When one understands visibility, one can
then make reasoned decisions about whether and when to add use clauses.

In decreasing order of specificity, the ways to call an operation in a pkg are

* Use the full name: Ada.Numerics.Elementary_Functions."**" (10.0, Logs)
This calls the operation once without changing its visibility
* Rename the operation:
function "**" (Left : Float; Right : Float) return Float renames
Ada.Numerics.Elementary_Functions."**";
This makes the specific operation visible
* Use type: this makes all operators of the type visible (not applicable
in this case)
* Use all type: this makes all operations of the type visible (not
applicable in this case)
* Use package: this makes everything in the package visible

Use pkg is clearly overkill for this case, and overuse of it can have negative
consequences.

--
Jeff Carter
"Choose a data representation that
makes the program simple."
Elements of Programming Style
188

Re: Gnat bug or mistaken program?

<6040e91a-fe01-447c-b508-174114f3101bn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5600&group=comp.lang.ada#5600

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:6214:dcf:: with SMTP id 15mr1314256qvt.34.1626886598767;
Wed, 21 Jul 2021 09:56:38 -0700 (PDT)
X-Received: by 2002:a25:dc50:: with SMTP id y77mr47705067ybe.405.1626886598596;
Wed, 21 Jul 2021 09:56:38 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 21 Jul 2021 09:56:38 -0700 (PDT)
In-Reply-To: <sd8lsv$crp$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC
NNTP-Posting-Host: 146.5.2.231
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
<ilo3o4F5297U1@mid.individual.net> <b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com>
<sd8lsv$crp$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6040e91a-fe01-447c-b508-174114f3101bn@googlegroups.com>
Subject: Re: Gnat bug or mistaken program?
From: onewinge...@gmail.com (Shark8)
Injection-Date: Wed, 21 Jul 2021 16:56:38 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Shark8 - Wed, 21 Jul 2021 16:56 UTC

On Wednesday, July 21, 2021 at 2:29:22 AM UTC-6, Jeffrey R. Carter wrote:
> > Thank you. So it is a visibility problem.
> "Understanding visibility is the key to understanding Ada." -- /Ada Distilled/
>
> Recommending the use package clause as a solution to a misunderstanding of
> visibility is a disservice to a beginning user. Widespread application of use
> pkg clauses is a crutch to avoid understanding visibility. I recommend that
> those who do not understand visibility avoid the use clause altogether, as this
> forces them to learn about visibility. When one understands visibility, one can
> then make reasoned decisions about whether and when to add use clauses.
>
> In decreasing order of specificity, the ways to call an operation in a pkg are
>
> * Use the full name: Ada.Numerics.Elementary_Functions."**" (10.0, Logs)
> This calls the operation once without changing its visibility
> * Rename the operation:
> function "**" (Left : Float; Right : Float) return Float renames
> Ada.Numerics.Elementary_Functions."**";
> This makes the specific operation visible
> * Use type: this makes all operators of the type visible (not applicable
> in this case)
> * Use all type: this makes all operations of the type visible (not
> applicable in this case)
> * Use package: this makes everything in the package visible
>
> Use pkg is clearly overkill for this case, and overuse of it can have negative
> consequences.
>
> --
> Jeff Carter
> "Choose a data representation that
> makes the program simple."
> Elements of Programming Style
> 188

This is excellent advice and an good list, though the last element should be two or three:
* Local, via declare-region/-scope; and
* ["local" via usage inside the spec, (perhaps in the public portion, perhaps in the private); and]
* Global (top of the file context-clauses).

Re: Gnat bug or mistaken program?

<d1ca9044-26e0-ebdd-43e6-02a08add4220@gmail.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5601&group=comp.lang.ada#5601

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!mRBVMlGoFUnDsRgMYRJiSw.user.46.165.242.75.POSTED!not-for-mail
From: haujekch...@gmail.com (Richard Iswara)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Thu, 22 Jul 2021 09:14:29 +0700
Organization: Aioe.org NNTP Server
Message-ID: <d1ca9044-26e0-ebdd-43e6-02a08add4220@gmail.com>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
<ilo3o4F5297U1@mid.individual.net>
<b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com> <sd8lsv$crp$1@dont-email.me>
<6040e91a-fe01-447c-b508-174114f3101bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="52743"; posting-host="mRBVMlGoFUnDsRgMYRJiSw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Richard Iswara - Thu, 22 Jul 2021 02:14 UTC

On 21/07/2021 23.56, Shark8 wrote:
> On Wednesday, July 21, 2021 at 2:29:22 AM UTC-6, Jeffrey R. Carter wrote:
>>> Thank you. So it is a visibility problem.
>> "Understanding visibility is the key to understanding Ada." -- /Ada Distilled/
>>
>> Recommending the use package clause as a solution to a misunderstanding of
>> visibility is a disservice to a beginning user. Widespread application of use
>> pkg clauses is a crutch to avoid understanding visibility. I recommend that
>> those who do not understand visibility avoid the use clause altogether, as this
>> forces them to learn about visibility. When one understands visibility, one can
>> then make reasoned decisions about whether and when to add use clauses.
>>
>> In decreasing order of specificity, the ways to call an operation in a pkg are
>>
>> * Use the full name: Ada.Numerics.Elementary_Functions."**" (10.0, Logs)
>> This calls the operation once without changing its visibility
>> * Rename the operation:
>> function "**" (Left : Float; Right : Float) return Float renames
>> Ada.Numerics.Elementary_Functions."**";
>> This makes the specific operation visible
>> * Use type: this makes all operators of the type visible (not applicable
>> in this case)
>> * Use all type: this makes all operations of the type visible (not
>> applicable in this case)
>> * Use package: this makes everything in the package visible
>>
>> Use pkg is clearly overkill for this case, and overuse of it can have negative
>> consequences.
>>
>> --
>> Jeff Carter
>> "Choose a data representation that
>> makes the program simple."
>> Elements of Programming Style
>> 188
>
> This is excellent advice and an good list, though the last element should be two or three:
> * Local, via declare-region/-scope; and
> * ["local" via usage inside the spec, (perhaps in the public portion, perhaps in the private); and]
> * Global (top of the file context-clauses).
>

Thank you all for your tips and explanations.

Re: Gnat bug or mistaken program?

<imaos8Fii64U1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5605&group=comp.lang.ada#5605

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Tue, 27 Jul 2021 19:00:08 +0300
Organization: Tidorum Ltd
Lines: 113
Message-ID: <imaos8Fii64U1@mid.individual.net>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
<ilo3o4F5297U1@mid.individual.net>
<b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com> <sd8lsv$crp$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net 8YhlTkiwLN6xHlyPacuZHgRw9pUnVFSNFqA3acQ/esGMaYJMmM
Cancel-Lock: sha1:JOea4FZVx3wlJEOd7BmtIpTv1b8=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.12.0
In-Reply-To: <sd8lsv$crp$1@dont-email.me>
Content-Language: en-US
 by: Niklas Holsti - Tue, 27 Jul 2021 16:00 UTC

I disagree with Jeffrey's opinion on what is a reasonable solution here.
More in-line below.

On 2021-07-21 11:29, Jeffrey R. Carter wrote:
> On 7/21/21 4:23 AM, Richard Iswara wrote:
>> On 20/07/2021 21.09, Niklas Holsti wrote:
>>> On 2021-07-20 15:02, Richard Iswara wrote:
>>>> I get this error on my program from the menu build => check semantic
>>>> exponent must be of type Natural, found type "Standard.Float".
>>>>
>>>> Should not 10 ** (log10 a + log10 b) = a*b?
>>>>
>>>> This is my compiler build:
>>>>
>>>> GNAT Studio Community 2020 (20200427) hosted on x86_64-pc-mingw32
>>>> GNAT Community 2020 (20200429-93) targetting x86_64-pc-mingw32
>>>> SPARK Community 2020 (20200429)
>>>>
>>>> Here is the relevant part of program:
>>>>
>>>> with Ada.Numerics.Elementary_Functions;
>>>> use Ada.Numerics;
>>>
>>>
>>> To make Ada.Numerics.Elementary_Functions."**" visible without
>>> qualification, you should also do "use
>>> Ada.Numerics.Elementary_Functions".
>>>
>>> Otherwise the compiler will see only the predefined operator:
>>>
>>>     function "**"(Left : Float; Right : Integer'Base) return Float
>>>
>>> (see RM 4.5.6(9 and 10)) which explains why the compiler does not
>>> accept a floating-point value as the Right operand to "**".
>>>
>>>
>>>> Logs : Float := 0.0;
>>>> Multiples : Float;
>>>     ...> Multiples := 10.0 ** Logs;  => this is where it fails
>>>
>>>
>>> It fails because the compiler sees only the predefined "**" operator
>>> which has an integral right operand.
>>
>> Thank you. So it is a visibility problem.
>
> "Understanding visibility is the key to understanding Ada." -- /Ada
> Distilled/

Hm. I agree visibility is important, but it is hardly the only important
Ada concept.

> Recommending the use package clause as a solution to a misunderstanding
> of visibility is a disservice to a beginning user.

Yes, unless the recommendation also includes explaining what the "use
package" does, thus increasing the user's understanding of visibility.

> In decreasing order of specificity, the ways to call an operation in a
> pkg are
>
> * Use the full name: Ada.Numerics.Elementary_Functions."**" (10.0, Logs)
>   This calls the operation once without changing its visibility

An application that needs "**" is likely to need other operators. Using
the fully qualified names makes non-trivial expressions much harder to
read and write. In the special case of a very few uses of very few
operators, I agree that this is a workable solution.

> * Rename the operation:
>   function "**" (Left : Float; Right : Float) return Float renames
>      Ada.Numerics.Elementary_Functions."**";
>   This makes the specific operation visible

Before Ada got "use type", such renaming declarations were the only
alternative to "use package", but they are verbose and proved (in my
experience, and that of others too) to be very error-prone, mainly when
renaming many operators -- copy-paste errors were rampant and hard to
find by reading. Interesting effects occur when "-" is renamed as "+" or
vice versa. I consider this solution to be the last (worst) choice.

> * Use type: this makes all operators of the type visible (not applicable
>   in this case)
> * Use all type: this makes all operations of the type visible (not
>   applicable in this case)

These are IMO usually the best methods but, as you say, not applicable here.

> * Use package: this makes everything in the package visible
>
> Use pkg is clearly overkill for this case,

I disagree. If the code uses several operators from the package, a "use
package" is apt (because "use type" does not apply here), but should of
course be as local as possible.

> and overuse of it can have negative consequences.

Agreed.

Re: Gnat bug or mistaken program?

<sdqph0$sjg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5606&group=comp.lang.ada#5606

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Wed, 28 Jul 2021 07:21:38 +0200
Organization: Adalog
Lines: 28
Message-ID: <sdqph0$sjg$1@dont-email.me>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com>
<ilo3o4F5297U1@mid.individual.net>
<b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com> <sd8lsv$crp$1@dont-email.me>
<imaos8Fii64U1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 28 Jul 2021 05:21:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9009b58b8ac011fe24fa131bd1d641eb";
logging-data="29296"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yOHvGtkvG1U8JrLUQD4iW"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:X7tWzRV4cyMwKDx5GS3e5RoQ2rU=
In-Reply-To: <imaos8Fii64U1@mid.individual.net>
Content-Language: fr
 by: J-P. Rosen - Wed, 28 Jul 2021 05:21 UTC

Le 27/07/2021 à 18:00, Niklas Holsti a écrit :
>> * Rename the operation:
>>    function "**" (Left : Float; Right : Float) return Float renames
>>       Ada.Numerics.Elementary_Functions."**";
>>    This makes the specific operation visible
>
>
> Before Ada got "use type", such renaming declarations were the only
> alternative to "use package", but they are verbose and proved (in my
> experience, and that of others too) to be very error-prone, mainly when
> renaming many operators -- copy-paste errors were rampant and hard to
> find by reading. Interesting effects occur when "-" is renamed as "+" or
> vice versa. I consider this solution to be the last (worst) choice.

With AdaControl, you can check that operators that are renamed as a
different operator:
check renaming_declarations
(not identical operator as_operator function);

(This syntax is from the soon-to-be-released new version of AdaControl -
wavefront available from GitHub: github.adalog.fr)

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Gnat bug or mistaken program?

<sdstod$qjo$1@franka.jacob-sparre.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5611&group=comp.lang.ada#5611

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Gnat bug or mistaken program?
Date: Wed, 28 Jul 2021 19:46:04 -0500
Organization: JSA Research & Innovation
Lines: 36
Message-ID: <sdstod$qjo$1@franka.jacob-sparre.dk>
References: <318e5e93-5f66-4bb8-8bf0-7ee3fd2688fan@googlegroups.com> <ilo3o4F5297U1@mid.individual.net> <b4af0c62-1376-393b-b8cf-67f6463cb50e@gmail.com> <sd8lsv$crp$1@dont-email.me> <imaos8Fii64U1@mid.individual.net>
Injection-Date: Thu, 29 Jul 2021 00:46:05 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="27256"; mail-complaints-to="news@jacob-sparre.dk"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
 by: Randy Brukardt - Thu, 29 Jul 2021 00:46 UTC

"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message
news:imaos8Fii64U1@mid.individual.net...
>I disagree with Jeffrey's opinion on what is a reasonable solution here.
>More in-line below.

You're being too hard on Jeff. See below.

.....
>> * Use package: this makes everything in the package visible
>>
>> Use pkg is clearly overkill for this case,
>
> I disagree. If the code uses several operators from the package, a "use
> package" is apt (because "use type" does not apply here), but should of
> course be as local as possible.

For general advice, this makes some sense, but in this specific case, there
is only one operator in this package so one of the other options makes more
sense than dragging in several dozen other names. Indeed, if there are
multiple uses of the operator, I'd probably use an expression function to
make the operator locally visible (this is similar to renames, using the
fullly qualified name). I'd only use a use package if there are many
routines in the package that are commonly used and well-understood from the
prespective of the system (GEF may be that for some systems, so perhaps I'm
being too hard on you. :-).

Side-issue: declaring operators that aren't primitive (so use-type doesn't
work) is suspicious. In most cases, operators belong with the type so that
they have the same visibility. The "**" for floats doesn't really belong in
GEF, it was put there for practical reasons (rather than good design) -- as
it is rather complex to describe and implement and isn't commonly used.

Randy.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor