Comments (4)
I don't think it improves the readability and the non-short circuit operators may give the compiler more opportunities for optimizing the code.
from orka.
Hi Onox,
Your statement that the compiler has more opportunities for optimizing the code with non short circuit operators is invalid.
See e.g. https://www.adaic.org/resources/add_content/docs/95style/html/sec_5/5-5-5.html and
In the absence of short-circuit forms, Ada does not provide a guarantee of the order of expression evaluation, nor does the language guarantee that evaluation of a relational expression is abandoned when it becomes clear that it evaluates to False (for and) or True (for or).
and https://perso.telecom-paristech.fr/pautet/Ada95/chap04.htm
The way the expressions are written in lines 26 through 29, all of the expressions will be evaluated when the statement is executed. If, in the case of line 26, the value of Index is not 12, then the final result will be FALSE no matter what the rest of the expressions are and it would be a waste of time to evaluate them. Ada will continue blindly across the entire line evaluating all of the expressions and wasting time since it should know the final result based on the first comparison. There is however, a way to tell it to stop as soon as it knows the final answer, through use of the short circuit operators.
from orka.
To find places where membership tests are preferred, our software only matches with pattern that use short-circuit operators.
I noticed that your code can benefit from membership tests at some locations,
see e.g. orka/src/orka/implementation/orka-frame_graphs.adb
- if Resource.Input_Mode /= Not_Used and Resource.Input_Mode /= Mode then
+ if Resource.Input_Mode not in Not_Used | Mode then
from orka.
and it would be a waste of time to evaluate them. Ada will continue blindly across the entire line evaluating all of the expressions
This information seems to be from the late 90s. Is this still the case with a modern version of GNAT? I would think that by using and
and or
you give the compiler more freedom to optimize.
see e.g. orka/src/orka/implementation/orka-frame_graphs.adb
Did not know I could combine an enum literal and a variable in membership test 😮
from orka.
Related Issues (20)
- Add Alire crates
- Remove GLFW bindings
- Support KTXorientation meta-data in KTX viewer tool
- Move origin of clip volume to upper-left
- Improve loading time of glTF models
- Add fallback to wl_surface.frame callback if user's Wayland compositor has no presentation-time
- Have a list of pressed and released buttons in keyboard state
- Scroll and relative pointer motion are not reset after reading pointer state
- Add gamepad with force-feedback/rumble support to AWT.Inputs
- Type Gamepad must be protected
- Have a list of pressed and released buttons in pointer state
- Compute orientation of gamepad using motion sensor
- Type Window must be protected
- Support getting/setting color of LED using CIE Lch(uv) color space
- Rewrite package tree Orka.Inputs.Joysticks to always use AWT.Inputs.Gamepads
- Add state objects to render passes in frame graph
- Improve readability
- Prefer if expression HOT 2
- What's reusable for OpenGL 3.3? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orka.