* 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
* Re: Use of expression function in protected type 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 0 siblings, 1 reply; 6+ messages in thread From: Egil H H @ 2015-01-21 8:35 UTC (permalink / raw) On Tuesday, January 20, 2015 at 11:34:54 PM UTC+1, Simon Wright wrote: > 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?) Just like a package can have subprograms declared in the public part, private part or the body, protected subprograms can be declared in the public part, private part or body of a protected type. (For example, it's not uncommon for a barrier function to be declared in the body.) And just like in a package body, forward declarations (or subprogram_declarations) are allowed for subprograms. However, an expression_function is allowed to complete a subprogram_declaration, but is not itself a subprogram_declaration (ARM 6.1(30/3). As far as I can tell, it's a basic_declaration, which is allowed in package specifications and bodies, but not in protected_operation_items. -- ~egilhh ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of expression function in protected type 2015-01-21 8:35 ` Egil H H @ 2015-01-21 9:15 ` Simon Wright 2015-01-21 20:44 ` Randy Brukardt 0 siblings, 1 reply; 6+ messages in thread From: Simon Wright @ 2015-01-21 9:15 UTC (permalink / raw) Egil H H <ehh.public@gmail.com> writes: > On Tuesday, January 20, 2015 at 11:34:54 PM UTC+1, Simon Wright wrote: >> 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?) > > Just like a package can have subprograms declared > in the public part, private part or the body, > protected subprograms can be declared in the public > part, private part or body of a protected type. > (For example, it's not uncommon for a barrier > function to be declared in the body.) One lives and learns! I've never had occasion to write a barrier _function_; my most complex barrier was when A or else not B or else (C and then not (D and then E)) > However, an expression_function is allowed > to complete a subprogram_declaration, but is not > itself a subprogram_declaration (ARM 6.1(30/3). > As far as I can tell, it's a basic_declaration, > which is allowed in package specifications and > bodies, but not in protected_operation_items. That was my reading, but I wondered whether it was deliberate, an oversight, or I'd missed something. The context was Emacs ada-mode, whose indentation engine is built on a parser, which follows the ARM. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of expression function in protected type 2015-01-21 9:15 ` Simon Wright @ 2015-01-21 20:44 ` Randy Brukardt 2015-01-22 2:50 ` Randy Brukardt 0 siblings, 1 reply; 6+ messages in thread From: Randy Brukardt @ 2015-01-21 20:44 UTC (permalink / raw) "Simon Wright" <simon@pushface.org> wrote in message news:ly8ugwo5pm.fsf@pushface.org... ... >> However, an expression_function is allowed >> to complete a subprogram_declaration, but is not >> itself a subprogram_declaration (ARM 6.1(30/3). >> As far as I can tell, it's a basic_declaration, >> which is allowed in package specifications and >> bodies, but not in protected_operation_items. > > That was my reading, but I wondered whether it was deliberate, an > oversight, or I'd missed something. Certainly not deliberate, I'm pretty sure no one ever considered it. We will now (I've forwarded a version of your message to Ada-Comment). Randy. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of expression function in protected type 2015-01-21 20:44 ` Randy Brukardt @ 2015-01-22 2:50 ` Randy Brukardt 2015-01-22 18:05 ` Simon Wright 0 siblings, 1 reply; 6+ messages in thread From: Randy Brukardt @ 2015-01-22 2:50 UTC (permalink / raw) I said: > Certainly not deliberate, I'm pretty sure no one ever considered it. We > will now (I've forwarded a version of your message to Ada-Comment). Early returns are that it is an oversight. It'll be on the agenda for next week's ARG phone call, and quite possibly it will get included in the upcoming Corrigendum. If so, it probably will be close to the fastest official Ada fix ever... Randy. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Use of expression function in protected type 2015-01-22 2:50 ` Randy Brukardt @ 2015-01-22 18:05 ` Simon Wright 0 siblings, 0 replies; 6+ messages in thread From: Simon Wright @ 2015-01-22 18:05 UTC (permalink / raw) "Randy Brukardt" <randy@rrsoftware.com> writes: > I said: > >> Certainly not deliberate, I'm pretty sure no one ever considered >> it. We will now (I've forwarded a version of your message to >> Ada-Comment). > > Early returns are that it is an oversight. It'll be on the agenda for > next week's ARG phone call, and quite possibly it will get included in > the upcoming Corrigendum. If so, it probably will be close to the > fastest official Ada fix ever... Wow! ^ 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