by Panzerschrek · 1mo ago · 0 comments
Good. My language has such ability too (if return type is specified as auto). But I do need a notation for some cases, like if no body definition is available or for recursive functions. How do you deal with recursion?
> the caller gets a warning when b is modified while the borrow is held
Why a warning and not an error?
@cpp_template("::tpy::min_key({0}, {1}, {2})", borrows=("a", "b"))
def min[T, K: Comparable](a: T, b: T, key: Fn[[T], K]) -> T: ...
(the result may borrow either a or b)Current approach is to warn because the checks are less precise than what I'd like them to. The idea is to keep it that way for now, migrate to CFG in the future and enable it in a strict mode.