octave-maintainers
[Top][All Lists]
Advanced

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

Re: Implementation of clear()


From: Thomas Weber
Subject: Re: Implementation of clear()
Date: Wed, 26 Dec 2007 10:02:22 +0100

Am Mittwoch, den 26.12.2007, 11:20 +0800 schrieb Ben Abbott:
> On Dec 26, 2007, at 3:53 AM, Thomas Weber wrote:
> 
> > Hi,
> >
> > the current implementation of clear() tries to mimic the M* approach  
> > for
> > a few arguments (namely all, functions, global, variables).
> >
> > I think it makes sense to add "exclusive" to this list. Consider the
> > following (3.0.0):
> >
> > ==========================================
> > octave3.0:25> a = 1; global b = 2;
> > octave3.0:26> clear -exclusive b
> > octave3.0:27> b,a
> > b =  2
> > error: `a' undefined near line 27 column 3
> > ==========================================
> > As expected, a is removed and b survives.
> 
> This functionality would be useful for me. However, it might encourage  
> sloppy programming habits ... something I'm quite familiar with ;-)
> 
> > ==========================================
> > octave3.0:27> a = 1; global b = 2;
> > octave3.0:28> clear exclusive b
> > octave3.0:29> a,b
> > a =  1
> > error: `b' undefined near line 29 column 3
> > ==========================================
> > Now, "b" is removed and "a" survives, which I find highly surprising.
> 
> You've asked to clear variables "b" and "exclusive". Although  
> "exclusive" was not defined, there is no error in either Octave or  
> Matlab when this is done. Thus, it would be equivalent to type "clear  
> b", which would clear variable "b" and leave "a" as it was.

The problem is that "exclusive" is specific compared with all other long
special names in that it makes a difference if I call it with or without
a dash:

"clear all" or "clear -all" are equivalent, but
"clear exclusive" or "clear -exclusive" aren't.

Matlab is unimportant in this case, as they don't have an 'exlusive'
switch (and god only knows why they need a "-regexp" switch).

Probably I should have mentioned it before: I'm trying to improve
clear()'s documentation by explaining the special keywords in its help.
If consensus is that all long keywords should only be called with a
dash, that's fine for me as well. But I think it's difficult to
understand that all long keywords may or may not have a dash prepended,
with the exception of "exclusive" (which would make it very exclusive,
indeed :)).

        Thomas





reply via email to

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