Skip to content

Use Quantified Expressions #15

Open
@pjljvandelaar

Description

@pjljvandelaar

Dear Developers,

Why don't you use Quantified Expressions at the following locations?

-      for R of VS loop
-         if not Satisfies (V, R) then
-            return False;
-         end if;
-      end loop;
-
-      return True;
+      return (for all R of VS => Satisfies (V, R));
             when Anded =>
                return OK : Boolean := True do
                   Trace ("AND children count:" & Trees.Child_Count (Pos)'Img);
-                  for Child in VS.Set.Iterate_Children (Pos) loop
-                     OK := OK and then Is_In (Child);
-                  end loop;
+                  OK :=
+                    OK
+                    and then
+                    (for all Child in VS.Set.Iterate_Children (Pos) =>
+                       Is_In (Child));
                end return;

Note that further simplifications are still possible ;-)

             when Ored =>
                return OK : Boolean := False do
                   Trace ("OR children count:" & Trees.Child_Count (Pos)'Img);
-                  for Child in VS.Set.Iterate_Children (Pos) loop
-                     OK := OK or else Is_In (Child);
-                  end loop;
+                  OK :=
+                    OK
+                    or else
+                    (for some Child in VS.Set.Iterate_Children (Pos) =>
+                       Is_In (Child));
                end return;

Note that also in this case further simplifications are still possible ;-)

Greetings,
Pierre

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions