Comments (9)
If we end up introducing non-short-circuiting variants, I think those should be the ones to get the longer name, as they're generally going to be dispreferred. Shortcircuiting is a real footgun, but it's rarely stumbled on.
After seeing how run conditions are used in practice, most conditions don't use change detection or event readers, which are the main worry.
We could add docs to the built in combinators that do as well to help warn users?
from bevy.
I think or_else
and and_then
are fine. It corresponds to methods on Option
with similar behavior so many users will already know how it works, plus it's a non-breaking change to go back to those names
from bevy.
@JoJoJet, spinning this out into an issue. We should resolve this one way or another for 0.15. I definitely agree with your concern, I just don't think that the names are a good way to communicate this :)
from bevy.
As evidenced by the fact that users regularly asked "why is it called and_then", and answerers didn't point to "oh that's because it's short-circuiting".
IMO that's the name having its intended effect. The problem is people not answering with the actual reason. The name is supposed to make you go 'huh that's weird, I wonder why it's named like that' so you go looking. If there's a simple name then it's really not clear that there's a huge asterisk when it comes to the system's heavior
from bevy.
I would argue that most are using the combinators to just achieve some logical output, that is without taking advantage of the short-circuiting behavior - but maybe there is a better solution here:
Maybe refactor interface to be:
Combinator | Short-Circuits | Logical equivalent |
---|---|---|
and | No | A & B |
and_short | Yes | A && B |
nand | No | !(A & B ) |
nand_short | Yes | !(A && B ) |
or | No | A | B |
or_short | Yes | A || B |
nor | No | !(A | B ) |
nor_short | Yes | !(A || B ) |
xor | No | A ^ B |
xnor | No | !(A ^ B ) |
This has the following advantages:
-
The name of the combinator used explicitly indicates whether or not it is short-circuiting by virtue of the
_short
suffix. This is much less ambiguous than_then
or_else
, enough to where I imagine if anybody is curious about what_short
means other users who know will probably give the "because it's short-circuiting" answer. -
No suffixes are added for non short-circuiting combinators. This should be straightforward for users who just want a simple logical output, and the intent (to my understanding) of the original pull request.
Disadvantages:
- This would probably bloat the interface some more.
from bevy.
For context, the short circuiting is actually mostly a performance optimization, rather than a deliberate behavioral choice.
from bevy.
For context, the short circuiting is actually mostly a performance optimization, rather than a deliberate behavioral choice.
Right - that's exactly what I thought. I imagine @JoJoJet 's concern is that perhaps there are users who deliberately want to take advantage of the behavior, and have it not be ambiguous.
from bevy.
If we end up introducing non-short-circuiting variants, I think those should be the ones to get the longer name, as they're generally going to be dispreferred
I really don't agree with this. Non short-circuiting should get the shorter name since it's more reliable and generally has fewer considerations. In general, I believe any option that is faster but requires you to know what you're doing should get a longer, more descriptive name
from bevy.
Hmm, fair. Let me bikeshed some names. If we add non-shortcircuiting nicely named variants I think I'm on board.
Candidates:
and_short
: mysterious, but short to readand_short_circuit
: very clear, rather a mouthfuland_then
: not obvious, same can't be used foror
and_&&
: is this even legal? It's definitely unidiomaticand_if
: short, legible, weird enough to pick up that something weird is going on
I think and_if
is my favorite, followed by and_short_circuit
. and_short
is fine, but meh. Everything else is pretty bad.
from bevy.
Related Issues (20)
- Observe should state that `Trigger<_>` must be first arg HOT 1
- Simple gizmo usage might trigger vulkan validation errors HOT 3
- Add MainScheduleOrder::insert_before() HOT 1
- Cross gizmo HOT 2
- Extended material example fails in browser HOT 2
- [Bug?] State is not updated when manually updating App HOT 7
- Bevy needs a better asset-hosting solution for example assets HOT 15
- Audio latency is higher than it needs to be HOT 12
- `bevy_render::Frustum` should live in `bevy_math` HOT 5
- Audio Sink Creation Delayed and Multiple Sinks Spawned HOT 1
- Observers don't trigger for Sparse components HOT 1
- Main branch fails to compile on Rust beta: doc list item missing indentation HOT 3
- Change detection of keyboard's resource `ButtonInput` is inconsistent
- Rapid repeated animation transitions break animation HOT 3
- Explain the pros and cons of each anti-aliasing technique HOT 1
- Add dependencies list for Gentoo Linux.
- Add resources for accumulated mouse motion and mouse scroll HOT 5
- `IntoSystemSetConfigs::chain_ignore_deferred` has wrong return type
- Lossy parse log filter if it comes from env variable
- Bevy `StateTransitionSteps` set is registered in app methods instead of states plugin HOT 1
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 bevy.