@verb #3797:"find_comm" this none this rxdo #833 @program #3797:"find_comm" this none this ":find_comm(who) => comm" "Find a communicator that can be used to talk to who; favour the one they are carrying, or one they own." {callee} = args valid(callee) || raise(E_INVARG) candidates = {} for o in ({@`callee:contents() ! E_VERBNF => {}', @`callee.location in {$limbo, "Other places of junk"} ? {} | callee.location:contents() ! E_INVIND, E_VERBNF => {}'}) o:isa($comm) && o:can_call(callee) && (candidates = {@candidates, o}) endfor if (!candidates) for comm in ($comm:descendants_suspended()) comm:can_call(callee) && (candidates = {@candidates, comm}) endfor endif best = $nothing bestscore = -1 for comm in (candidates) score = (comm.location == callee ? 2 | 0) + (comm.owner == callee ? 1 | 0) score > bestscore && ({best, bestscore} = {comm, score}) endfor return best .