Comments (4)
This is a clever way to implement unreachable, but I don't like it. It's too hard to use properly. An unreachable()
function or macro seems to be a much safer and more ergonomic implementation.
EDIT: it can be applied to blocks in upcoming versions (thanks for the correction below). A Base.@assume_effects
is annotated at the function level. This makes it too coarse-grained to use responsibly for this purpose.:nothrow
annotation like this would also seem to risk applying recursively to any functions called (or at least to inlined functions), which makes this dangerous in the first place and a maintenance nightmare if any of those called functions ever change.
I think we shouldn't have this for many of the same reasons we don't have global @fastmath
(any more).
from julia.
Not true, since v1.11 @assume_effects
may be appllied to a code block: https://docs.julialang.org/en/v1.12-dev/base/base/#Base.@assume_effects. For example the nothrow
below should only apply to the 7::Union{}
AFAIK:
Base.@assume_effects :nothrow let
7::Union{}
end
Obviously unreachable()
is intrinsically unsafe, however, given that we can apply nothrow
to a code block, I think my proposal is as safe as possible?
from julia.
Not true, since v1.11
Thanks for the correction. I vaguely recalled seeing something like that but it's hard to keep up with all the upcoming changes.
Really, you're right that (in at least some senses) @assume_effects
should have this power. Otherwise it's not really assuming the stated effects. Although taking that line of thinking further, we should allow any provable violation of an effects flag to emit an unreachable.
That said, as far as I understand (though my understanding is poor), @assume_effects
has virtually no impact on the internal operation of the function it's defined on. Its impact is actually on call sites of that function. Given that understanding, this proposal would dramatically expand the scope of @assume_effects
's operation. So it seems like the wrong place for this functionality.
I also don't relish the idea of encouraging people to impose blatantly false effects to twist the compiler into emitting unreachable. There should be a more direct option (although it could co-exist with the proposed feature).
from julia.
xref #54436
from julia.
Related Issues (20)
- `make test-all` does not emit error even if test dependencies are missing in stdlib
- Document to use nightly Julia to contribute to the standard library HOT 2
- Over/underflow in complex power function
- Proposed Negation Default Broadcast Behavior HOT 4
- Dotplot not overlaying violin plot HOT 1
- Filenames on Windows in coverage output are missing drive letter HOT 2
- Add ability to specify multiple paths via --code-coverage=@<path>
- ^C inside pkg-add prompt causes assertion abort
- Argument destructuring returned from macro accidentally assigns global
- Potentially erring paths in matrix logarithms HOT 1
- `nm -D --with-symbol-versions` unreliable
- julia1.10.4 using CUDA ERROR: failed to parse TOML output from running "~/.julia/packages/CUDA_Runtime_jll/VNnmC/.pkg/select_artifacts.jl", got: TOML Parser error: none:1:7 error: expected equal sign after key
- Stack overflow during gc_read_stack on win32 HOT 2
- Make an `isdense` trait HOT 8
- `factorize(<:AbstractMatrix)` prefers `Cholesky` but `factorize(<:Hermitian)` prefers `BunchKaufman` HOT 2
- Concurrent program crashes 1.12 nightly build (1.10 is fine) HOT 1
- Intermittent segmentation fault while running CFITSIO tests on nightly HOT 2
- Conversion to pointer not defined for `Base.ReinterpretArray` on v1.11 and above HOT 2
- Julia Rejecting this target due to use of runtime-disabled feature HOT 3
- Base.PersistentDict/HAMT: rehashing is ineffective HOT 4
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 julia.