Package org.ek9lang.compiler.support.retention
package org.ek9lang.compiler.support.retention
-
ClassDescriptionTHE write of a derived RETAINS rule: marks the callable as DERIVED and adds the rule text.THE argument question the argument readers ask (
RetainsArgument,HandsBackArgument,KeepsArgumentBeyondResult,DefinitelyKeepsArgument,MayKeepArgument), so they differ only in which rules count (wanted) and in whether theunknownopt-out answers for them (unknownCounts): does a rule ofcallee(declared, derived, or the generic's own) that matcheswantedtake the argument given atparameterIndexas its source? WithunknownCounts, a callee declaringunknownanswers yes - also for an index it does not declare.THE declared parameters of a method, operator or function a RETAINS rule names; none for anything else.THE method or function a recorded symbol CALLS, when it is a call that hands back a value made elsewhere: a method, operator or function call - never a constructor, whose result is always fresh.THE method, operator or function an expression CALLS when the whole expression is that call -a.get(k),first(),a + b,(a.get(k))- so its value is whatever the call handed back.THE reading of a callee's RETAINS as the ESCAPE facts of one call (E1.1, 2026-11-12, EK9_IR_ESCAPE_LIFETIME_AND_SHARING_FACTS.md ยง3 "argument sinks"): for each argument, which holders may come to hold it (the receiver, other parameters by name - the whole argument or a part of it), whether it may be kept somewhere no argument names (ambient, or an abstract declaration nothing implements), and whether it may be handed back in the result; for the receiver, which parameters it (or a part of it) is kept into and whether it is kept ambiently; for the result, whether it may be a view of the receiver, and the fail-closed default of an un-annotated extern (UndeclaredExternResult); and theunknownopt-out, under which nothing may be assumed.What becomes of one argument.The escape facts of one callee.THE copy of every RETAINS rule of one callable onto another, parameters matched BY POSITION and re-named as the target declares them:return <- receiver-interioras it is, a kept receiver's destination re-named, a returned or kept parameter (or a part of one) by the target's parameter at the same position.Does the callee (or, for a member of a parameterised type, the generic's own member) declare a rule matchingwanted- or theunknownopt-out, under which nothing may be assumed.Doescalleesay, by an EXPLICIT rule - declared by a built-in or derived for a user callable - that it keeps the argument it is given atparameterIndexsomewhere other than its result? The narrower question thanKeepsArgumentBeyondResult, which also counts the inexpressibleunknownopt-out: an unnamed closeable given to a callee that DEFINITELY keeps it is E81072; one given to a callee that may is handed on.Doescalleesay, by an EXPLICIT rule - declared by a built-in (readyHandler <- receiver) or derived for a user method - that it keeps the object it is called ON beyond the call: stores it in an argument or where nothing here can name it? The receiver's half ofDefinitelyKeepsArgument: an unnamed closeable that is the RECEIVER of such a call is E81072 (D80 follow-up, 2026-10-21:Tracked("r").registerIn(kept), whose body isitems += this, closed the receiver and then the list held a closed object).May the call hand the argument it is given atparameterIndexback as (part of) its result -return <- <that parameter>? The narrower question thanRetainsArgument, which also counts an argument kept anywhere else (receiver <- item) and theunknownopt-out: the closeable ownership decision reports a hand-back (E81072) and treats any other keeping as handed on.Was the callee's retention DERIVED by phase 5 (a user callable) rather than DECLARED (a built-in's@Ek9Retains)? The closeable ownership decision treats the two differently: a derived link is honoured only where the return type may hold a borrowed view (support/BorrowedViewReturn).Maycalleekeep the argument it is given atparameterIndexsomewhere other than its result - into its receiver, another argument, or anywhere (receiver <- item,unknown)? The question a constructor passing its own parameter on asks to know whether the parameter outlives the construction.Maycalleekeep its receiver beyond the call - an explicit rule, or theunknownopt-out?A rule saying the RECEIVER itself is kept:<parameter> <- receiverorambient <- receiver.What may come to HOLD the argumentcalleeis given atparameterIndex, other than its result: the receiver (RetentionRule.RECEIVER) and the names of the other parameters it may store the argument into (receiver <- item,items <- item).THE rules a delegated trait's FORWARDER takes (with trait of Keeper by impl; the derivation audit's M5, 2026-11-15): the forwarder has no source - phase 7 emitsimpl.keep(n)- so it has no body to derive from and was read as keeping nothing, though the delegate keeps what it is given.THE rules a BODY-LESS dynamic function inherits (option B slice B, Steve 2026-11-13):intTransformer <- () is transformValue of Integer as functionhas no body of its own, so phase 7 emits its_callas a forward to its super function with every parameter - the super's body IS what it does with its arguments, and its super's rules (declared or derived, a parameterised generic's own included -RulesOf) are its rules, parameters matched by position and named as the dynamic function declares them (CopyRetentionRules, the mirror ofMarkOverriddenBy's UP union: that one climbs only up, so a body-less sub derived nothing and every caller trusted it - E1a'sscenario3SimpleContainershape).Record, on a user method, operator or function, that the argument given for a parameter may be kept beyond the call - the rule<destination> <- <parameter>(RetentionRule.destination()andRetentionRule.source()), exactly the text a built-in declares: the destination isreceiver(stored in a property of the object), another parameter's name (added to the object that argument refers to),ambient(held where nothing here can name it: a capture, a returned closure, a call that keeps it) orReturnRetention.UNIMPLEMENTED.Record, on a user method or operator, that the object it is called on may be kept beyond the call -<destination> <- receiver, exactly the text a built-in declares (HTTP.whenReady'sreadyHandler <- receiver): the destination is another parameter's name (the receiver is stored in what that argument refers to) orambient(held where nothing here can name it: a capture, a returned closure, a call that keeps it).Record that an abstract declaration nothing implements MAY keep each of its arguments (unimplemented <- <parameter>,ReturnRetention.UNIMPLEMENTED); the keep counterpart ofMarkReturnsEachParameter.THE dispatch union (Steve, 2026-10-21, D61): a call throughdeclarationmay runoverride- a method that overrides it, or a function (dynamic functions included) whose super function it is - so the declaration also returns whatever the override does, and keeps whatever the override keeps (the lane callee-keep, 2026-10-21:receiver <- item,<otherParam> <- item,ambient <- item).An abstract declaration no program code implements: which implementation runs cannot be known, so its result may be any of its arguments -return <- <each parameter>.Record, on a user method, operator or function, that what it returns may be the argument given for the parameterparameterName-return <- parameterName, exactly the text a built-in declares (List.getOrDefault'sreturn <- defaultValue).Record, on a user method or operator, that what it returns is (part of) its receiver (ReturnRetention.RECEIVER_INTERIOR, exactly the text a built-in declares).Does whatcalleereturns possibly share an object with its receiver or an argument: it declares (or has derived)return <- receiver-interiororreturn <- <parameter>, or theunknownopt-out - or it is an extern that declares nothing at all and whose result can reach a user object, which is read the conservative way (UndeclaredExternResult, D7').The MAY half ofDefinitelyKeepsArgument: doescalleesay, by an EXPLICIT rule, that it keeps the argument - or is it an abstract declaration nothing implements, which MAY keep any argument (ReturnRetention.UNIMPLEMENTED)? An unnamed closeable given to such a callee is E81072 (nothing could close it); a named try resource given to it is allowed.THE index of the parameter a RETAINS rule names (parameterName) incallee's declared parameters; -1 when it declares none of that name.The parameterscalleestores its receiver INTO by an explicit rule (items <- receiver, declared or derived): the names of the arguments that end up holding the object it is called on.Maycalleekeep (a reference to) the argument it is given atparameterIndex- into its receiver, another argument, its result or anywhere else (receiver <- item,return <- other, orunknown)? An argument the callee keeps is no longer the caller's alone.The RETAINS text of the callee itself and of the generic it is a parameterisation, or member, of.THE reading ofCommonValues.RETAINS- what a call's RESULT may share with what it was called on, and which arguments (or receiver) a callee may keep.THE rules saying whatcalleeRETURNS (everyreturn <- sourceit declares or has derived, the generic's own for a parameterisation or a member of one) - for a caller that must map each source back onto the receiver or the argument it names (phase5/ReturnSourceKind.origins).Does whatcalleereturns possibly share an object with its RECEIVER.Every rule the callee declares or has derived, the generic's own included; none forunknown.THE fail-closed default of the RESULT side of the retention trust boundary (D7', Steve 2026-11-12; the master plan's M1): an externally implemented callable that declares NO@Ek9Retainsat all, whose result type can reach a user object (MayHoldUserObject), hands back something that MAY alias its receiver or an argument.