comp.lang.ada
 help / color / mirror / Atom feed
* Use of expression function in protected type
@ 2015-01-20 22:34 Simon Wright
  2015-01-21  8:35 ` Egil H H
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 2015-01-20 22:34 UTC (permalink / raw)


Is it permissible to use an expression function as the completion of a
protected function? (GNAT thinks so).

   protected Button
   is
      function Current_Index return Interval_Index;
   private
      Index : Interval_Index := 0;
      procedure Handler;
      pragma Attach_Handler (Handler, Ada.Interrupts.Names.EXTI0_IRQ);
   end Button;

and then

   protected body Button is
      function Current_Index return Interval_Index is (Index); -- <<<<<<<<
      procedure Handler is
      begin
         HAL_GPIO_EXTI_IRQHandler (16#0001#);
         Index := Index + 1;
      end Handler;
   end Button;

ARM 6.1(30) distinguishes an expression_function_declaration from a
subprogram_declaration.

6.8(4) allows an expression_function_declaration to be a completion.

9.4(8) says a protected_operation_item can be, inter alia, a
subprogram_declaration or a subprogram body. (subprogram_declaration?
how can that be?)

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

end of thread, other threads:[~2015-01-22 18:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-20 22:34 Use of expression function in protected type Simon Wright
2015-01-21  8:35 ` Egil H H
2015-01-21  9:15   ` Simon Wright
2015-01-21 20:44     ` Randy Brukardt
2015-01-22  2:50       ` Randy Brukardt
2015-01-22 18:05         ` Simon Wright

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