mislocked

Tests whether a function file is locked in memory.

Category: Programming > Functions

Syntax

tf = mislocked

Tests the function that calls it.

tf = mislocked(name)

Tests the function named name.

Description

A function becomes locked when it calls mlock; munlock unlocks it. A locked function keeps its persistent variables when clear is used, so mislocked tells whether a clear would reset them. A function that never called mlock is not locked.

Input arguments

name
Function name, as text.

Output arguments

tf
true if the function is locked.

Example

Before the function has run

writelines(["function r = counter()", "  mlock;", "  persistent n", "  if isempty(n), n = 0; end", "  n = n + 1; r = n;", "end"], 'counter.m');
mislocked('counter')
Output
ans = logical
   0

See also

mlock munlock clear