comp.lang.ada
 help / color / mirror / Atom feed
* Unreferenced parameters
@ 2021-02-03 18:20 Simon Wright
  2021-02-03 18:50 ` Egil H H
  2021-02-04  3:12 ` Randy Brukardt
  0 siblings, 2 replies; 14+ messages in thread
From: Simon Wright @ 2021-02-03 18:20 UTC (permalink / raw)


In gps-editors.ads:1492, in GNAT Studio, I have

   overriding function Expand_Tabs
     (This   : Dummy_Editor_Buffer;
      Line   : Editable_Line_Type;
      Column : Character_Offset_Type) return Visible_Column_Type is (0);

and FSF GCC 10.1.0 says

 gps-editors.ads:1494:07: warning: formal parameter "Line" is not referenced
 gps-editors.ads:1495:07: warning: formal parameter "Column" is not referenced

which is clearly the case (how does it know that it's OK not to
reference This? it must check the context).

The compilation is set to treat warnings as errors (-gnatwe) so I need
to suppress these warnings.

I could do so with pragma Warnings (Off, "formal*not referenced");

I have done so by renaming the parameters Dummy_Line, Dummy_Column.

But is there a way of using aspect or pragma Unreferenced? Putting
pragma Unreferenced after the function definition doesn't work.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 18:20 Unreferenced parameters Simon Wright
@ 2021-02-03 18:50 ` Egil H H
  2021-02-03 18:53   ` Egil H H
  2021-02-04  3:12 ` Randy Brukardt
  1 sibling, 1 reply; 14+ messages in thread
From: Egil H H @ 2021-02-03 18:50 UTC (permalink / raw)


On Wednesday, February 3, 2021 at 7:20:12 PM UTC+1, Simon Wright wrote:
> In gps-editors.ads:1492, in GNAT Studio, I have 
> 
> overriding function Expand_Tabs 
> (This : Dummy_Editor_Buffer; 
> Line : Editable_Line_Type; 
> Column : Character_Offset_Type) return Visible_Column_Type is (0); 
> 
> 
> But is there a way of using aspect or pragma Unreferenced? Putting 
> pragma Unreferenced after the function definition doesn't work.

pragma Unreferenced usually goes in the body:

procedure Foo(Bar : Integer) is
   pragma Unreferenced(Bar);
begin
   null;
end Foo;

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 18:50 ` Egil H H
@ 2021-02-03 18:53   ` Egil H H
  2021-02-03 19:29     ` Dmitry A. Kazakov
  2021-02-03 19:32     ` Simon Wright
  0 siblings, 2 replies; 14+ messages in thread
From: Egil H H @ 2021-02-03 18:53 UTC (permalink / raw)


On Wednesday, February 3, 2021 at 7:50:59 PM UTC+1, Egil H H wrote:
> On Wednesday, February 3, 2021 at 7:20:12 PM UTC+1, Simon Wright wrote: 
> > In gps-editors.ads:1492, in GNAT Studio, I have 
> > 
> > overriding function Expand_Tabs 
> > (This : Dummy_Editor_Buffer; 
> > Line : Editable_Line_Type; 
> > Column : Character_Offset_Type) return Visible_Column_Type is (0); 
> > 
> >
> > But is there a way of using aspect or pragma Unreferenced? Putting 
> > pragma Unreferenced after the function definition doesn't work.
> pragma Unreferenced usually goes in the body: 
> 
> procedure Foo(Bar : Integer) is 
> pragma Unreferenced(Bar); 
> begin 
> null; 
> end Foo;

oh!
Sorry, I must have missed that you're asking about an expression function...

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 18:53   ` Egil H H
@ 2021-02-03 19:29     ` Dmitry A. Kazakov
  2021-02-04 10:48       ` Simon Wright
  2021-02-03 19:32     ` Simon Wright
  1 sibling, 1 reply; 14+ messages in thread
From: Dmitry A. Kazakov @ 2021-02-03 19:29 UTC (permalink / raw)


On 2021-02-03 19:53, Egil H H wrote:

> Sorry, I must have missed that you're asking about an expression function...

Mixing implementations and interfaces is such a bad idea. I try to avoid 
these and aspects and even "is null" implementations.

I recently discovered yet another reason. When building an encapsulated 
library, shoveling implementations inside the specification breaks the 
library interface because implementation packages must with-ed there. 
When with-ed from the bodies, as it should be, the library interface 
includes only what it really must.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 18:53   ` Egil H H
  2021-02-03 19:29     ` Dmitry A. Kazakov
@ 2021-02-03 19:32     ` Simon Wright
  2021-02-03 22:27       ` Shark8
  1 sibling, 1 reply; 14+ messages in thread
From: Simon Wright @ 2021-02-03 19:32 UTC (permalink / raw)


Egil H H <ehh.public@gmail.com> writes:

> Sorry, I must have missed that you're asking about an expression function...

Yes, I should have been clearer.

I've had hints before from (different) AdaCore staff that they'd prefer
the 'is (0);' on a new line, which would definitely make it more obvious.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 19:32     ` Simon Wright
@ 2021-02-03 22:27       ` Shark8
  0 siblings, 0 replies; 14+ messages in thread
From: Shark8 @ 2021-02-03 22:27 UTC (permalink / raw)


On Wednesday, February 3, 2021 at 12:32:21 PM UTC-7, Simon Wright wrote:
> Egil H H <ehh.p> writes: 
> 
> > Sorry, I must have missed that you're asking about an expression function...
> Yes, I should have been clearer. 
> 
> I've had hints before from (different) AdaCore staff that they'd prefer 
> the 'is (0);' on a new line, which would definitely make it more obvious.
I typically do "is" new-line indented-expression.

Function Example return integer is
   ( 1 );
 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 18:20 Unreferenced parameters Simon Wright
  2021-02-03 18:50 ` Egil H H
@ 2021-02-04  3:12 ` Randy Brukardt
  2021-02-04 10:27   ` Simon Wright
  1 sibling, 1 reply; 14+ messages in thread
From: Randy Brukardt @ 2021-02-04  3:12 UTC (permalink / raw)


We (the ARG) recently added an allowance for aspect specifications on 
parameters and a few other constructs. The reason in part was because we 
didn't want to restrict where implementation-defined aspects can be placed, 
and the motivating case was aspect Unreferenced.

So I'd guess that you can put the aspect directly on the parameters in the 
usual way (but that may require a compiler not available yet; the change was 
approved in Sept [AI12-0395-1] and Oct [AI12-0398-1]). So, I'd expect the 
following to work (eventually):

 overriding function Expand_Tabs
     (This   : Dummy_Editor_Buffer with Unreferenced;
      Line   : Editable_Line_Type with Unreferenced;
      Column : Character_Offset_Type with Unreferenced) return 
Visible_Column_Type is (0);

                             Randy.




"Simon Wright" <simon@pushface.org> wrote in message 
news:lyim79c8ti.fsf@pushface.org...
> In gps-editors.ads:1492, in GNAT Studio, I have
>
>   overriding function Expand_Tabs
>     (This   : Dummy_Editor_Buffer;
>      Line   : Editable_Line_Type;
>      Column : Character_Offset_Type) return Visible_Column_Type is (0);
>
> and FSF GCC 10.1.0 says
>
> gps-editors.ads:1494:07: warning: formal parameter "Line" is not 
> referenced
> gps-editors.ads:1495:07: warning: formal parameter "Column" is not 
> referenced
>
> which is clearly the case (how does it know that it's OK not to
> reference This? it must check the context).
>
> The compilation is set to treat warnings as errors (-gnatwe) so I need
> to suppress these warnings.
>
> I could do so with pragma Warnings (Off, "formal*not referenced");
>
> I have done so by renaming the parameters Dummy_Line, Dummy_Column.
>
> But is there a way of using aspect or pragma Unreferenced? Putting
> pragma Unreferenced after the function definition doesn't work.
> 


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-04  3:12 ` Randy Brukardt
@ 2021-02-04 10:27   ` Simon Wright
  2021-02-09 11:16     ` Egil H H
  0 siblings, 1 reply; 14+ messages in thread
From: Simon Wright @ 2021-02-04 10:27 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> We (the ARG) recently added an allowance for aspect specifications on 
> parameters and a few other constructs. The reason in part was because we 
> didn't want to restrict where implementation-defined aspects can be placed, 
> and the motivating case was aspect Unreferenced.
>
> So I'd guess that you can put the aspect directly on the parameters in the 
> usual way (but that may require a compiler not available yet; the change was 
> approved in Sept [AI12-0395-1] and Oct [AI12-0398-1]). So, I'd expect the 
> following to work (eventually):
>
>  overriding function Expand_Tabs
>      (This   : Dummy_Editor_Buffer with Unreferenced;
>       Line   : Editable_Line_Type with Unreferenced;
>       Column : Character_Offset_Type with Unreferenced) return 
> Visible_Column_Type is (0);

As you say, not yet. But .. looking good!

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-03 19:29     ` Dmitry A. Kazakov
@ 2021-02-04 10:48       ` Simon Wright
  0 siblings, 0 replies; 14+ messages in thread
From: Simon Wright @ 2021-02-04 10:48 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> I recently discovered yet another reason. When building an
> encapsulated library, shoveling implementations inside the
> specification breaks the library interface because implementation
> packages must with-ed there. When with-ed from the bodies, as it
> should be, the library interface includes only what it really must.

This applies to any standalone library, I think.

Now you've pointed it out, I'll certainly avoid using an expression
function in a spec that requires me to 'with' (or 'private with')
another package that I wasn't going to 'with' anyway.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-04 10:27   ` Simon Wright
@ 2021-02-09 11:16     ` Egil H H
  2021-02-09 18:54       ` Stephen Leake
  0 siblings, 1 reply; 14+ messages in thread
From: Egil H H @ 2021-02-09 11:16 UTC (permalink / raw)


On Thursday, February 4, 2021 at 11:27:14 AM UTC+1, Simon Wright wrote:
> > overriding function Expand_Tabs 
> > (This : Dummy_Editor_Buffer with Unreferenced; 
> > Line : Editable_Line_Type with Unreferenced; 
> > Column : Character_Offset_Type with Unreferenced) return 
> > Visible_Column_Type is (0);
> As you say, not yet. But .. looking good!

It's included in the New Features list of GNAT Pro 21.1


-- 
~egilhh


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-09 11:16     ` Egil H H
@ 2021-02-09 18:54       ` Stephen Leake
  2021-02-09 21:20         ` Simon Wright
  2021-02-11  3:20         ` Randy Brukardt
  0 siblings, 2 replies; 14+ messages in thread
From: Stephen Leake @ 2021-02-09 18:54 UTC (permalink / raw)


Egil H H <ehh.public@gmail.com> writes:

> On Thursday, February 4, 2021 at 11:27:14 AM UTC+1, Simon Wright wrote:
>> > overriding function Expand_Tabs 
>> > (This : Dummy_Editor_Buffer with Unreferenced; 
>> > Line : Editable_Line_Type with Unreferenced; 
>> > Column : Character_Offset_Type with Unreferenced) return 
>> > Visible_Column_Type is (0);
>> As you say, not yet. But .. looking good!
>
> It's included in the New Features list of GNAT Pro 21.1

Sigh. Now I have to add that to ada-mode, in the grammar and in
ada-format-parameter-list.

How do we want this indented when 'with ...' is on a new line:

overriding function Expand_Tabs 
  (This   : Some.Very_Long.Subtype_Name
            with Unreferenced; 
   Line   : Editable_Line_Type with Unreferenced; 
   Column : Character_Offset_Type with Unreferenced)
return Visible_Column_Type
is (0);

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-09 18:54       ` Stephen Leake
@ 2021-02-09 21:20         ` Simon Wright
  2021-02-11  3:20         ` Randy Brukardt
  1 sibling, 0 replies; 14+ messages in thread
From: Simon Wright @ 2021-02-09 21:20 UTC (permalink / raw)


Stephen Leake <stephen_leake@stephe-leake.org> writes:

> Egil H H <ehh.public@gmail.com> writes:
>
>> On Thursday, February 4, 2021 at 11:27:14 AM UTC+1, Simon Wright wrote:
>>> > overriding function Expand_Tabs 
>>> > (This : Dummy_Editor_Buffer with Unreferenced; 
>>> > Line : Editable_Line_Type with Unreferenced; 
>>> > Column : Character_Offset_Type with Unreferenced) return 
>>> > Visible_Column_Type is (0);
>>> As you say, not yet. But .. looking good!
>>
>> It's included in the New Features list of GNAT Pro 21.1
>
> Sigh. Now I have to add that to ada-mode, in the grammar and in
> ada-format-parameter-list.
>
> How do we want this indented when 'with ...' is on a new line:
>
> overriding function Expand_Tabs 
>   (This   : Some.Very_Long.Subtype_Name
>             with Unreferenced; 
>    Line   : Editable_Line_Type with Unreferenced; 
>    Column : Character_Offset_Type with Unreferenced)
> return Visible_Column_Type
> is (0);

Of course we can't yet know what the compiler will be happy with! (with
-gnaty, I mean)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-09 18:54       ` Stephen Leake
  2021-02-09 21:20         ` Simon Wright
@ 2021-02-11  3:20         ` Randy Brukardt
  2021-02-11 20:18           ` Stephen Leake
  1 sibling, 1 reply; 14+ messages in thread
From: Randy Brukardt @ 2021-02-11  3:20 UTC (permalink / raw)


"Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
news:86blct1393.fsf@stephe-leake.org...
...
>> It's included in the New Features list of GNAT Pro 21.1
>
> Sigh. Now I have to add that to ada-mode, in the grammar and in
> ada-format-parameter-list.

While you're at it, you probably ought to add any other contexts where 
aspect_specifications are now allowed:

    parameter_specification
    discriminant_specification
    extended_return_object_declaration
    entry_index_specification

It's likely someone will define an aspect that works in some or all of these 
contexts, as well as the 40 or so existing contexts. (I'm assuming that 
Ada-Mode isn't intended to be only for GNAT.) We've allowed 
aspect_specifications pretty much everywhere that they might be useful. (See 
AI12-0398-1 for a detailed analysis.) They're also allowed in various 
parallel constructs, but you may not have worked on those yet.

Note that AI12-0398-1 suggests that Unreferenced would be useful on an 
entry_index_specification, since the identifier is not optional (giving it a 
similar problem to parameters).

                                 Randy.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Unreferenced parameters
  2021-02-11  3:20         ` Randy Brukardt
@ 2021-02-11 20:18           ` Stephen Leake
  0 siblings, 0 replies; 14+ messages in thread
From: Stephen Leake @ 2021-02-11 20:18 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Stephen Leake" <stephen_leake@stephe-leake.org> wrote in message 
> news:86blct1393.fsf@stephe-leake.org...
> ...
>>> It's included in the New Features list of GNAT Pro 21.1
>>
>> Sigh. Now I have to add that to ada-mode, in the grammar and in
>> ada-format-parameter-list.
>
> While you're at it, you probably ought to add any other contexts where 
> aspect_specifications are now allowed:
>
>     parameter_specification
>     discriminant_specification
>     extended_return_object_declaration
>     entry_index_specification

Thanks for the heads up. I think I'll wait until ada 2021 is finally
done, then do another diff between annex P and my grammar.

> (I'm assuming that 
> Ada-Mode isn't intended to be only for GNAT.) 

correct.

-- 
-- Stephe

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-02-11 20:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 18:20 Unreferenced parameters Simon Wright
2021-02-03 18:50 ` Egil H H
2021-02-03 18:53   ` Egil H H
2021-02-03 19:29     ` Dmitry A. Kazakov
2021-02-04 10:48       ` Simon Wright
2021-02-03 19:32     ` Simon Wright
2021-02-03 22:27       ` Shark8
2021-02-04  3:12 ` Randy Brukardt
2021-02-04 10:27   ` Simon Wright
2021-02-09 11:16     ` Egil H H
2021-02-09 18:54       ` Stephen Leake
2021-02-09 21:20         ` Simon Wright
2021-02-11  3:20         ` Randy Brukardt
2021-02-11 20:18           ` Stephen Leake

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