julia
julia copied to clipboard
Make `Base.donotdelete` public
I rely on Base.donotdelete in Chairmarks.jl and I'd like it to be public. I imagine that other benchmarking tools also rely on it. It's been around since 1.8 (see also: #55773) and I think we should commit to keeping it functional for the rest of 1.x.
donotdelete is actually defined in Core, and it's a built-in, as opposed to a generic function. As far as I understand exposing non-generic functions isn't a good practice. Perhaps it'd make sense to define something like this in Base, and make that public:
function donotdelete(args...)
Core.donotdelete(args)
end
Rust exposes very similar functionality here:
- https://doc.rust-lang.org/beta/std/hint/fn.black_box.html
Also some C++ libraries (implemented using inline assembly). For example, folly has doNotOptimizeAway.
Tagging Triage as this expands the public API
What's wrong with exposing builtin functions?
Exporting a public generic function seems like it'd be of somewhat questionable utility, too. Are there any upsides to letting users override this function? I can only think of downsides.
Are there any upsides to letting users override this function? I can only think of downsides.
I suppose you're right and past me was wrong. Not really sure though. Hoping someone who knows for sure chimes in on triage.
BTW there are Git conflicts here.
Triage thinks it's fine (and best) to ~export~ publicize the builtin rather than adding a layer of indirection.
Triage approves adding this to public API as Base.donotdelete.