Static.jl
Static types useful for dispatch and generated functions.
Install / Use
/learn @SciML/Static.jlREADME
Static
Static defines a set of types (True, False, StaticInt{value::Int}, StaticFloat64{value::Float64}, StaticSymbol{value::Symbol}) that may be dispatched on (similar to Base.Val{value}). Unlike Base.Val, instances of these types provide "static" values (meaning known at compile time) that in many cases work interchangeably with dynamic values (meaning the value is known at runtime but not compile time). This is particularly useful when designing types whose fields may be dynamically or statically known, such as a range whose size may be dynamic or statically known.
Generic conversions to static values, dynamic values, and compile-time-known values are accomplished with the methods static, dynamic, and known, respectively.
julia> using Static
julia> static(1)
static(1)
julia> dynamic(static(1))
1
julia> dynamic(1)
1
julia> typeof(static(1))
StaticInt{1}
julia> known(typeof(static(1)))
1
julia> known(typeof(1)) === nothing # `Int` has no compile-time-known value
true
Types, Dispatch, Compile-Time, and StaticNumbers.jl
Static.jl does not subtype the Base number types. For example, !(StaticInt <: Integer). The reason for this is that it
invalidates all downstream compilation caches. This has a major effect, for example, causing LoopVectorization.jl to
not precompile and ultimately giving the ODE solvers >20 second extra compile times. To avoid these invalidations, the
dispatches were removed. An alternative library StaticNumbers.jl is
more ergonomic but has these invalidations. Use the library that is more appropriate for your use case.
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
