Skip to content

Commit d354a67

Browse files
Document the explicit FunctionWrappersWrapper{FW, P, CS}(fw, cs) constructor
`FunctionWrappersWrapper` is exported, so its inner constructor was already reachable as public API, but it carried no docstring — the only constructor of the type that did not. Downstream solver stacks construct through exactly this method, because supplying `FW`, `P` and `CS` directly keeps the wrapper type inferrable without relying on constant propagation through a keyword-argument frame, which the `argtypes`/`rettypes` and tuple constructors do. The docstring is attached with `@doc` on the method signature after the struct; a docstring written inside the struct body does not attach to the type's binding, so Documenter would never render it. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
1 parent ee57b5a commit d354a67

4 files changed

Lines changed: 696 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FunctionWrappersWrappers"
22
uuid = "77dc65aa-8811-40c2-897b-53d922fa7daf"
33
authors = ["Chris Elrod <elrodc@gmail.com> and contributors"]
4-
version = "1.11.0"
4+
version = "1.11.1"
55

66
[deps]
77
FunctionWrappers = "069b7b12-0de2-55c6-9aab-29f3d0a68a2e"

src/FunctionWrappersWrappers.jl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,50 @@ end
225225

226226
TruncatedStacktraces.@truncate_stacktrace FunctionWrappersWrapper
227227

228+
@doc """
229+
FunctionWrappersWrapper{FW, P, CS}(fw, cs) -> FunctionWrappersWrapper{FW, P, CS}
230+
231+
Create a `FunctionWrappersWrapper` from an already-built wrapper tuple and cache storage,
232+
with every type parameter fixed by the caller.
233+
234+
This is the fully explicit form. Prefer it when the result type must be inferrable from
235+
type parameters alone: `FW`, `P` and `CS` are given directly rather than derived from
236+
argument values, so nothing rests on constant propagation through a keyword-argument
237+
frame. Solver stacks that wrap a type-erased callable — where the wrapper type, and every
238+
cache built from it, must stay concrete — construct through this method.
239+
240+
The caller is responsible for consistency: `fw` must match `FW`, and `cs` must be the
241+
storage type `P`'s fallback path expects — [`NoCacheStorage`](@ref),
242+
[`SingleCacheStorage`](@ref), or [`DictCacheStorage`](@ref), matching the intended cache
243+
mode.
244+
245+
# Arguments
246+
- `fw`: Tuple of `FunctionWrappers.FunctionWrapper`s, tried in order on call.
247+
- `cs`: Cache storage instance used by the fallback path.
248+
249+
# Type Parameters
250+
- `FW`: Tuple type of the wrapped `FunctionWrapper`s.
251+
- `P`: Fallback policy type, such as `Strict`, `AllowAll`, or `AllowNonIsBits`.
252+
- `CS`: Cache storage type, matching `typeof(cs)`.
253+
254+
# Returns
255+
- `FunctionWrappersWrapper{FW, P, CS}`: A callable wrapper around `fw`.
256+
257+
# Examples
258+
```jldoctest
259+
julia> using FunctionWrappers: FunctionWrapper
260+
261+
julia> fw = (FunctionWrapper{Float64, Tuple{Float64, Float64}}(+),);
262+
263+
julia> cs = FunctionWrappersWrappers.SingleCacheStorage();
264+
265+
julia> fww = FunctionWrappersWrapper{typeof(fw), AllowNonIsBits, typeof(cs)}(fw, cs);
266+
267+
julia> fww(1.0, 2.0)
268+
3.0
269+
```
270+
""" FunctionWrappersWrapper{FW, P, CS}(fw::FW, cs::CS) where {FW, P, CS}
271+
228272
"""
229273
FunctionWrappersWrapper{FW, P, CS}(f) -> FunctionWrappersWrapper{FW, P, CS}
230274

0 commit comments

Comments
 (0)