From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.147.136 with SMTP id v130mr7294945iod.28.1472322363061; Sat, 27 Aug 2016 11:26:03 -0700 (PDT) X-Received: by 10.157.6.44 with SMTP id 41mr704269otn.10.1472322363038; Sat, 27 Aug 2016 11:26:03 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!x131no468162ite.0!news-out.google.com!d68ni40892ith.0!nntp.google.com!j128no468897ith.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 27 Aug 2016 11:26:02 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=50.250.26.106; posting-account=3pYsyQoAAACcI-ym7XtMOI2PDU8gRZS5 NNTP-Posting-Host: 50.250.26.106 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <60637c3a-c699-4e4c-9fd3-1a081cb6152c@googlegroups.com> Subject: Select + Accept syntax question From: Andrew Shvets Injection-Date: Sat, 27 Aug 2016 18:26:03 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31605 Date: 2016-08-27T11:26:02-07:00 List-Id: Hello, When working with tasks, you can use a selective wait in order to have your= task quickly check its queue of messages and see if there any waiting for = it (i.e. a selective wait.) Now, in order to further build on this, guards= can be used to ensure that certain conditions are met before processing so= me messages. After messing around with both concepts, I created the following example: while Go_Loop LOOP select when Internal_Value =3D 0 =3D> accept Input(Value : in Integer) do Internal_Value :=3D Value; end Input; or when Internal_Value /=3D 0 =3D> accept Retrieve(Value : out Integer) do Value :=3D Internal_Value; end Retrieve; The one thing that threw me for a loop was when I put any type of code righ= t before the above two accept keywords, like so: while Go_Loop LOOP select when Internal_Value =3D 0 =3D> Ada.Text_IO.Put_Line("hello world"); accept Input(Value : in Integer) do Internal_Value :=3D Value; end Input; or when Internal_Value /=3D 0 =3D> Ada.Text_IO.Put_Line("hello world"); accept Retrieve(Value : out Integer) do Value :=3D Internal_Value; end Retrieve; And I get the following output from the compiler: > gnatmake -g .\task_demo_11.adb gcc -c -I.\ -g -I- .\task_demo_11.adb task_demo_11.adb:25:16: missing "END SELECT;" for "SELECT" at line 18 task_demo_11.adb:25:17: select alternative ("ACCEPT", "ABORT", "DELAY") exp= ected task_demo_11.adb:38:07: "OR" not allowed here task_demo_11.adb:42:07: no "SELECT" for this "END SELECT" gnatmake: ".\task_demo_11.adb" compilation error Why does this happen? Why can't I have code right before the accept? I ca= n see a compilation error if there is no accept...