Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sequencer-2-2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
epics-modules
sequencer-2-2
Commits
8255d2dc
Commit
8255d2dc
authored
11 years ago
by
benjamin.franksen
Browse files
Options
Downloads
Patches
Plain Diff
docs: added a note regarding lazy evaluation of logical operators
parent
13b98ed4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
documentation/Reference.txt
+17
-11
17 additions, 11 deletions
documentation/Reference.txt
with
17 additions
and
11 deletions
documentation/Reference.txt
+
17
−
11
View file @
8255d2dc
...
@@ -1042,6 +1042,13 @@ Left-associative Binary Operators
...
@@ -1042,6 +1042,13 @@ Left-associative Binary Operators
expr: `expr` "&" `expr`
expr: `expr` "&" `expr`
expr: `expr` "%" `expr`
expr: `expr` "%" `expr`
.. note:: Like in most programming languages, evaluation of conditional
expressions using ``&&`` and ``||`` is done *lazily*: the second operand
is not evaluated if evaluation of the first already determines the
result. This particularly applies to the boolean expressions in
:token:`transition` clauses. See the built-in function :c:func:`pvGetQ`
for an extended discussion.
Ternary Operator
Ternary Operator
~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~
...
@@ -1461,22 +1468,21 @@ combining a call to pvGetQ with other conditions in the same
...
@@ -1461,22 +1468,21 @@ combining a call to pvGetQ with other conditions in the same
} state ...
} state ...
would remove the head from the queue every time the condition gets
would remove the head from the queue every time the condition gets
evaluated, regardless of whether ``other_condition`` is ``TRUE``. This is most
evaluated, regardless of whether ``other_condition`` is ``TRUE``. This is
probably not the desired effect, as you would lose an
most probably not the desired effect, as you would lose an unknown number of
unknown number of messages. (Of course it *could* be exactly what you want,
messages. (Of course it *could* be exactly what you want, for instance if
especially if ``other_condition`` were in fact ``!suppress_output``.)
``other_condition`` were something like ``!suppress_output``.) Whereas ::
Whereas ::
when (other_condition && pvGetQ(msg)) {
when (other_condition && pvGetQ(msg)) {
printf(msg);
printf(msg);
} state ...
} state ...
is "safe", in the sense that no messages will be lost. BTW, If you
is "safe", in the sense that no messages will be lost. BTW, If you
combine
combine
with a disjunction ("||") it is the other way around, i.e. pvGetQ
with a disjunction ("||") it is the other way around, i.e. pvGetQ
should
should
appear as the first operand. This is all merely a result of the
appear as the first operand. This is all merely a result of the
evaluation
evaluation
order imposed by the C language; similar remarks apply
order imposed by the C language
(and thus by SNL)
; similar remarks apply
whenever you want to use an expression inside a :token:`transition` clause
that
whenever you want to use an expression inside a :token:`transition` clause
potentially has a side-effect.
that
potentially has a side-effect.
pvFreeQ
pvFreeQ
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment