Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Round Numbers are always false. -- Samuel Johnson


devel / comp.lang.ada / Re: Rosetta Code task Proper divisors fails to compile

SubjectAuthor
* Rosetta Code task Proper divisors fails to compileKenneth Wolcott
`* Re: Rosetta Code task Proper divisors fails to compileJeffrey R.Carter
 `* Re: Rosetta Code task Proper divisors fails to compileKenneth Wolcott
  `* Re: Rosetta Code task Proper divisors fails to compileJeffrey R.Carter
   `- Re: Rosetta Code task Proper divisors fails to compileKenneth Wolcott

1
Rosetta Code task Proper divisors fails to compile

<71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:8785:0:b0:76c:43b5:3563 with SMTP id j127-20020a378785000000b0076c43b53563mr2493qkd.0.1690346990633;
Tue, 25 Jul 2023 21:49:50 -0700 (PDT)
X-Received: by 2002:a05:6808:1819:b0:3a4:2943:8f7 with SMTP id
bh25-20020a056808181900b003a4294308f7mr2679344oib.5.1690346990361; Tue, 25
Jul 2023 21:49:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 25 Jul 2023 21:49:49 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com>
Subject: Rosetta Code task Proper divisors fails to compile
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Wed, 26 Jul 2023 04:49:50 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1763
 by: Kenneth Wolcott - Wed, 26 Jul 2023 04:49 UTC

Hi;

Trying to understand (and use) a Rosetta Code task (Proper divisors)...

https://rosettacode.org/wiki/Proper_divisors#Ada

it fails to compile

gnatmake -vh ./proper_divisors.adb

GNATMAKE 13.1.0
Copyright (C) 1992-2023, Free Software Foundation, Inc.
"proper_divisors.ali" being checked ...
-> "proper_divisors.ali" missing.
gcc -c -I./ -I- ./proper_divisors.adb
generic_divisors.ads:11:08: error: (Ada 2005) cannot copy object of a limited type (RM-2005 6.5(5.5/2))
generic_divisors.ads:11:08: error: return by reference not permitted in Ada 2005
End of compilation
gnatmake: "./proper_divisors.adb" compilation error

Why does this work for the the submitter of the Rosetta Code task and not for me?

Thanks,
Ken Wolcott

Re: Rosetta Code task Proper divisors fails to compile

<u9qlts$1elnt$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Rosetta Code task Proper divisors fails to compile
Date: Wed, 26 Jul 2023 10:36:12 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <u9qlts$1elnt$1@dont-email.me>
References: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Jul 2023 08:36:12 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9303d613505a01ab2b53e729460eace7";
logging-data="1529597"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Tvzmxxotgf3+rG8VmcZbsECbLKVPx1TE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:pKbgYq34O1q0akYN2sOKTlfo+F8=
In-Reply-To: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com>
Content-Language: en-US
 by: Jeffrey R.Carter - Wed, 26 Jul 2023 08:36 UTC

On 2023-07-26 06:49, Kenneth Wolcott wrote:
>
> https://rosettacode.org/wiki/Proper_divisors#Ada
>
> gnatmake -vh ./proper_divisors.adb
>
> generic_divisors.ads:11:08: error: (Ada 2005) cannot copy object of a limited type (RM-2005 6.5(5.5/2))
> generic_divisors.ads:11:08: error: return by reference not permitted in Ada 2005
>
> Why does this work for the the submitter of the Rosetta Code task and not for me?

For some reason your gnatmake seems to be defaulting to -gnat05 mode. This code
has an expression function, which is Ada 12, so try adding -gnat12 to the command.

You also should not need to put "./" in front of the file name, though I don't
see how that would make a difference.

--
Jeff Carter
"I'm a lumberjack and I'm OK."
Monty Python's Flying Circus
54

Re: Rosetta Code task Proper divisors fails to compile

<c9868ca1-84c8-41d9-be3c-bd58432e87b5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:102:b0:402:b71e:90e5 with SMTP id u2-20020a05622a010200b00402b71e90e5mr8114qtw.4.1690396213326;
Wed, 26 Jul 2023 11:30:13 -0700 (PDT)
X-Received: by 2002:a05:6808:1888:b0:38d:ca0a:8e18 with SMTP id
bi8-20020a056808188800b0038dca0a8e18mr619513oib.2.1690396213099; Wed, 26 Jul
2023 11:30:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 26 Jul 2023 11:30:12 -0700 (PDT)
In-Reply-To: <u9qlts$1elnt$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
References: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com> <u9qlts$1elnt$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c9868ca1-84c8-41d9-be3c-bd58432e87b5n@googlegroups.com>
Subject: Re: Rosetta Code task Proper divisors fails to compile
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Wed, 26 Jul 2023 18:30:13 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2205
 by: Kenneth Wolcott - Wed, 26 Jul 2023 18:30 UTC

On Wednesday, July 26, 2023 at 1:36:15 AM UTC-7, Jeffrey R.Carter wrote:
> For some reason your gnatmake seems to be defaulting to -gnat05 mode. This code
> has an expression function, which is Ada 12, so try adding -gnat12 to the command.
>
> You also should not need to put "./" in front of the file name, though I don't
> see how that would make a difference.

Hi Jeff;

Thank you for your suggestion. Doesn't seem to have any effect.

(*SIGH*)

gnatmake -vh -gnat2012 proper_divisors.adb

GNATMAKE 13.1.0
Copyright (C) 1992-2023, Free Software Foundation, Inc.
"proper_divisors.ali" being checked ...
-> "proper_divisors.ali" missing.
gcc -c -gnat2012 proper_divisors.adb
generic_divisors.ads:11:08: error: (Ada 2005) cannot copy object of a limited type (RM-2005 6.5(5.5/2))
generic_divisors.ads:11:08: error: return by reference not permitted in Ada 2005
End of compilation
gnatmake: "proper_divisors.adb" compilation error

Ken

Re: Rosetta Code task Proper divisors fails to compile

<u9rtrh$1hutd$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spam.jrcarter.not@spam.acm.org.not (Jeffrey R.Carter)
Newsgroups: comp.lang.ada
Subject: Re: Rosetta Code task Proper divisors fails to compile
Date: Wed, 26 Jul 2023 21:57:37 +0200
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <u9rtrh$1hutd$1@dont-email.me>
References: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com>
<u9qlts$1elnt$1@dont-email.me>
<c9868ca1-84c8-41d9-be3c-bd58432e87b5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 26 Jul 2023 19:57:37 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="983f2e8298054c59f21c59c0da0031b5";
logging-data="1637293"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++LxxNT6PfUt9Tq3XEzoGKnOr1M8L3/fM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:zowlo/F4YMXLYUp+3MGIqJUUbT8=
In-Reply-To: <c9868ca1-84c8-41d9-be3c-bd58432e87b5n@googlegroups.com>
Content-Language: en-US
 by: Jeffrey R.Carter - Wed, 26 Jul 2023 19:57 UTC

On 2023-07-26 20:30, Kenneth Wolcott wrote:
>
> Thank you for your suggestion. Doesn't seem to have any effect.

Interesting. I get the same results with GNAT 12.

Looking more closely at the code, I think the error, while its msg is
misleading, is correct. A function that returns a limited type can only return
an aggregate, a function call, or an object declared by an extended return
statement. The generic formal object None is none of these.

Changing the generic parameter to a function

with function None return Result_Type;

makes the code correct. You need to change the definition of Empty in
Proper_Divisors

function Empty return Pos_Arr is (1 .. 0 => <>);

and create a function to supply for the 2nd instantiation

function None return Natural is (0);
....
package Divisor_Count is new Generic_Divisors
(Result_Type => Natural, None => None, One => Cnt, Add => "+");

and then it compiles and runs.

Another possibility is to make Result_Type simply private, though that is
slightly less general. That may be how the OP got the code to compile and run.
It might be that limited was added later because the OP saw that it could be,
and never tested the change.

--
Jeff Carter
"I'm a lumberjack and I'm OK."
Monty Python's Flying Circus
54

Re: Rosetta Code task Proper divisors fails to compile

<e9fce00e-7fd0-4ce0-a874-acb29d4e0e80n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:198a:b0:403:ab15:17a0 with SMTP id u10-20020a05622a198a00b00403ab1517a0mr11211qtc.12.1690410389506;
Wed, 26 Jul 2023 15:26:29 -0700 (PDT)
X-Received: by 2002:a4a:4fd5:0:b0:563:6b94:ab7f with SMTP id
c204-20020a4a4fd5000000b005636b94ab7fmr1154150oob.1.1690410388757; Wed, 26
Jul 2023 15:26:28 -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, 26 Jul 2023 15:26:28 -0700 (PDT)
In-Reply-To: <u9rtrh$1hutd$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=98.59.238.112; posting-account=oHOvdQoAAACYgyEBjgPNvKFOGxg8pNns
NNTP-Posting-Host: 98.59.238.112
References: <71e087e7-bfb2-4659-b218-134fb265d479n@googlegroups.com>
<u9qlts$1elnt$1@dont-email.me> <c9868ca1-84c8-41d9-be3c-bd58432e87b5n@googlegroups.com>
<u9rtrh$1hutd$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e9fce00e-7fd0-4ce0-a874-acb29d4e0e80n@googlegroups.com>
Subject: Re: Rosetta Code task Proper divisors fails to compile
From: kennethwolcott@gmail.com (Kenneth Wolcott)
Injection-Date: Wed, 26 Jul 2023 22:26:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Kenneth Wolcott - Wed, 26 Jul 2023 22:26 UTC

On Wednesday, July 26, 2023 at 12:57:40 PM UTC-7, Jeffrey R.Carter wrote:
> On 2023-07-26 20:30, Kenneth Wolcott wrote:
> >
> > Thank you for your suggestion. Doesn't seem to have any effect.
> Interesting. I get the same results with GNAT 12.
>
> Looking more closely at the code, I think the error, while its msg is
> misleading, is correct. A function that returns a limited type can only return
> an aggregate, a function call, or an object declared by an extended return
> statement. The generic formal object None is none of these.
>
> Changing the generic parameter to a function
>
> with function None return Result_Type;
>
> makes the code correct. You need to change the definition of Empty in
> Proper_Divisors
>
> function Empty return Pos_Arr is (1 .. 0 => <>);
>
> and create a function to supply for the 2nd instantiation
>
> function None return Natural is (0);
> ...
> package Divisor_Count is new Generic_Divisors
> (Result_Type => Natural, None => None, One => Cnt, Add => "+");
>
> and then it compiles and runs.
>
> Another possibility is to make Result_Type simply private, though that is
> slightly less general. That may be how the OP got the code to compile and run.
> It might be that limited was added later because the OP saw that it could be,
> and never tested the change.

Hi Jeff;

Thank you for your reply.

I went with the latter suggestion for my local use.

Ken

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor