octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compatibility considerations of "clear"


From: Ben Abbott
Subject: Re: Compatibility considerations of "clear"
Date: Wed, 14 Aug 2013 12:24:59 -0400

On Aug 14, 2013, at 12:17 PM, Philipp Kutin wrote:

> In Octave, issuing a plain "clear" clears both workspace and global
> variables. This is a little surprising to someone working with MATLAB,
> but from the command line it's only a minor issue. However, it may
> have compatibility implications when used from a function.
> 
> There does exist M code in the wild that calls "clear"
> programmatically. I guess that it's mostly people feeling clearing
> data manually sometimes, but occasionally, it can be justified. For
> example, when reading in some large data and reordering it to
> normalize to one's convention -- it may be a sensible move to clear a
> temp variable before the function returns if further memory-intensive
> operations are subsequently carried out.
> 
> I propose making plain "clear" only clear the workspace-local
> variables, and adding an option "-a"/"-all" for the current behavior.
> What do you think?
> 
> --Philipp

From Matlab ...

-----------
If X is global, clear X removes X from the current workspace, but
leaves it accessible to any functions declaring it global. 
clear GLOBAL X completely removes the global variable X. 
clear GLOBAL -REGEXP PAT removes global variables that match regular
expression patterns.
-----------

Octave is intended to be compatible with Matlab, so this is a bug.  Would you 
file a bug report?

        https://savannah.gnu.org/bugs/?group=octave

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]