Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4722 > unrolled thread

Re: Quit versus Clear["Global`*"]

Started byMurray Eisenberg <murray@math.umass.edu>
First post2011-09-03 21:56 +0000
Last post2011-09-06 08:04 +0000
Articles 8 — 5 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Quit versus Clear["Global`*"] Murray Eisenberg <murray@math.umass.edu> - 2011-09-03 21:56 +0000
    Re: Quit versus Clear["Global`*"] AES <siegman@stanford.edu> - 2011-09-04 08:13 +0000
    Re: Quit versus Clear["Global`*"] Murray Eisenberg <murray@math.umass.edu> - 2011-09-04 22:07 +0000
    Re: Quit versus Clear["Global`*"] DrMajorBob <btreat1@austin.rr.com> - 2011-09-04 22:09 +0000
    Re: Quit versus Clear["Global`*"] DrMajorBob <btreat1@austin.rr.com> - 2011-09-05 11:07 +0000
    Re: Quit versus Clear["Global`*"] "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-09-06 07:56 +0000
    Re: Quit versus Clear["Global`*"] Murray Eisenberg <murray@math.umass.edu> - 2011-09-06 07:58 +0000
    Re: Quit versus Clear["Global`*"] Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-09-06 08:04 +0000

#4722 — Re: Quit versus Clear["Global`*"]

FromMurray Eisenberg <murray@math.umass.edu>
Date2011-09-03 21:56 +0000
SubjectRe: Quit versus Clear["Global`*"]
Message-ID<j3u7r6$a88$1@smc.vnet.net>
First, Clear, whether for a single object or an entire list of objects, 
does not remove their Attributes, e.g., just their values. You might 
want ClearAll instead.

Second, did you try evaluating one of the following?

   ?Quit
   ?Quit*

Or looking up Quit (or even "quit") in the Documentation Center? That 
will answer your second question!


On 9/3/11 8:05 AM, Themis Matsoukas wrote:
> What is the difference between quitting the kernel and executing Clear["Global`*"]?
>
> Is there a command to quit the kernel, instead of selecting Quit/Local from there Evaluate menu?
>
> Thanks
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

[toc] | [next] | [standalone]


#4739

FromAES <siegman@stanford.edu>
Date2011-09-04 08:13 +0000
Message-ID<j3vbvn$ej4$1@smc.vnet.net>
In reply to#4722
In article <j3u7r6$a88$1@smc.vnet.net>,
 Murray Eisenberg <murray@math.umass.edu> wrote:

> First, Clear, whether for a single object or an entire list of objects, 
> does not remove their Attributes, e.g., just their values. You might 
> want ClearAll instead. 

And how do either of those differ from Remove?

[toc] | [prev] | [next] | [standalone]


#4744

FromMurray Eisenberg <murray@math.umass.edu>
Date2011-09-04 22:07 +0000
Message-ID<j40sqg$l16$1@smc.vnet.net>
In reply to#4722
Try the following little three-part experiment.  In each part, the last 
step tells you what Mathematica now knows about the symbol f.

    f[x_] := Plot[x, {x, 0, 1}]
    SetAttributes[f, Listable]
    Clear[f]
    ??f

    f[x_] := Plot[x, {x, 0, 1}]
    SetAttributes[f, Listable]
    ClearAll[f]
    ??f

    f[x_] := Plot[x, {x, 0, 1}]
    SetAttributes[f, Listable]
    Remove[f]
    ??f

On 9/4/11 4:12 AM, AES wrote:
> In article<j3u7r6$a88$1@smc.vnet.net>,
>   Murray Eisenberg<murray@math.umass.edu>  wrote:
>
>> First, Clear, whether for a single object or an entire list of objects,
>> does not remove their Attributes, e.g., just their values. You might
>> want ClearAll instead.
>
> And how do either of those differ from Remove?
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

[toc] | [prev] | [next] | [standalone]


#4749

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-09-04 22:09 +0000
Message-ID<j40sva$l23$1@smc.vnet.net>
In reply to#4722
Remove[x] perniciously changes the definition of symbols that mention x,  
replacing x with Removed[x] and making those definitions useless. Clear[x]  
removes definitions for x, but leaves alone other symbols that mention  
it... which, to me, seems far more sensible.

After Clear[x], other symbols referring to x can still be used (with or  
without new definitions for x). After Remove[x], all those symbols are  
just trash, lying around waiting for Quit to clear them away.

Bobby

On Sun, 04 Sep 2011 03:12:58 -0500, AES <siegman@stanford.edu> wrote:

> In article <j3u7r6$a88$1@smc.vnet.net>,
>  Murray Eisenberg <murray@math.umass.edu> wrote:
>
>> First, Clear, whether for a single object or an entire list of objects,
>> does not remove their Attributes, e.g., just their values. You might
>> want ClearAll instead.
>
> And how do either of those differ from Remove?
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [next] | [standalone]


#4754

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-09-05 11:07 +0000
Message-ID<j42ahb$rnp$1@smc.vnet.net>
In reply to#4722
Your experiment makes Remove look useful (possibly), but here's one that  
does not:

ClearAll[f]
f[x_] := Plot[x, {x, 0, 1}] SetAttributes[f, Listable]
Remove[x]
?? f

Remove[x] cripples f without mentioning it, which I'd call a very ugly  
side-effect.

Bobby

On Sun, 04 Sep 2011 17:05:26 -0500, Murray Eisenberg  
<murray@math.umass.edu> wrote:

> Try the following little three-part experiment.  In each part, the last
> step tells you what Mathematica now knows about the symbol f.
>
>     f[x_] := Plot[x, {x, 0, 1}]
>     SetAttributes[f, Listable]
>     Clear[f]
>     ??f
>
>     f[x_] := Plot[x, {x, 0, 1}]
>     SetAttributes[f, Listable]
>     ClearAll[f]
>     ??f
>
>     f[x_] := Plot[x, {x, 0, 1}]
>     SetAttributes[f, Listable]
>     Remove[f]
>     ??f
>
> On 9/4/11 4:12 AM, AES wrote:
>> In article<j3u7r6$a88$1@smc.vnet.net>,
>>   Murray Eisenberg<murray@math.umass.edu>  wrote:
>>
>>> First, Clear, whether for a single object or an entire list of objects,
>>> does not remove their Attributes, e.g., just their values. You might
>>> want ClearAll instead.
>>
>> And how do either of those differ from Remove?
>>
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [next] | [standalone]


#4766

From"Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Date2011-09-06 07:56 +0000
Message-ID<j44jnm$8tr$1@smc.vnet.net>
In reply to#4722
This is not a side-effect; it is necessary in order for the symbol to be  
removed. Retaining any references whatsoever will prevent the symbol from  
being deleted from the symbol table due to Mathematica's  
reference-counting garbage collection. When calling Remove, one explicitly  
requests that the symbol be completely removed, and this is duly performed  
along with all that it implies. If one only wishes to clear the  
definitions on a symbol rather than destroying the symbol itself, the use  
of Remove would be erroneous, since this quite separate operation is the  
domain of ClearAll.

A situation in which Remove might be needed is where a function has  
created temporary symbols and wishes to destroy them before returning in  
order to avoid clogging up the symbol table (which would represent a  
memory leak and may slightly worsen Mathematica's performance). Although  
the Temporary attribute could be used instead, catching all the references  
may not be easy, so Remove is helpful in that it automatically invalidates  
any references that would otherwise have prevented garbage collection. In  
other words, Remove is a specialised function with a specialised use, not  
simply an alternative to Clear/Unset et al.

On Mon, 05 Sep 2011 12:07:23 +0100, DrMajorBob <btreat1@austin.rr.com>  
wrote:

> Your experiment makes Remove look useful (possibly), but here's one that
> does not:
>
> ClearAll[f]
> f[x_] := Plot[x, {x, 0, 1}] SetAttributes[f, Listable]
> Remove[x]
> ?? f
>
> Remove[x] cripples f without mentioning it, which I'd call a very ugly
> side-effect.
>
> Bobby
>
> On Sun, 04 Sep 2011 17:05:26 -0500, Murray Eisenberg
> <murray@math.umass.edu> wrote:
>
>> Try the following little three-part experiment.  In each part, the last
>> step tells you what Mathematica now knows about the symbol f.
>>
>>     f[x_] := Plot[x, {x, 0, 1}]
>>     SetAttributes[f, Listable]
>>     Clear[f]
>>     ??f
>>
>>     f[x_] := Plot[x, {x, 0, 1}]
>>     SetAttributes[f, Listable]
>>     ClearAll[f]
>>     ??f
>>
>>     f[x_] := Plot[x, {x, 0, 1}]
>>     SetAttributes[f, Listable]
>>     Remove[f]
>>     ??f
>>
>> On 9/4/11 4:12 AM, AES wrote:
>>> In article<j3u7r6$a88$1@smc.vnet.net>,
>>>   Murray Eisenberg<murray@math.umass.edu>  wrote:
>>>
>>>> First, Clear, whether for a single object or an entire list of  
>>>> objects,
>>>> does not remove their Attributes, e.g., just their values. You might
>>>> want ClearAll instead.
>>>
>>> And how do either of those differ from Remove?
>>>
>>

[toc] | [prev] | [next] | [standalone]


#4772

FromMurray Eisenberg <murray@math.umass.edu>
Date2011-09-06 07:58 +0000
Message-ID<j44jqi$8vv$1@smc.vnet.net>
In reply to#4722
I never recommended use of Remove! In fact, if Clear or ClearAll or 
ClearAttributes doesn't do what I want, then typically I restart the kernel.

On 9/4/11 10:44 PM, DrMajorBob wrote:
> Your experiment makes Remove look useful (possibly), but here's one that
> does not:
>
> ClearAll[f]
> f[x_] := Plot[x, {x, 0, 1}] SetAttributes[f, Listable]
> Remove[x]
> ?? f
>
> Remove[x] cripples f without mentioning it, which I'd call a very ugly
> side-effect.
>
> Bobby
>
> On Sun, 04 Sep 2011 17:05:26 -0500, Murray Eisenberg
> <murray@math.umass.edu> wrote:
>
>> Try the following little three-part experiment. In each part, the last
>> step tells you what Mathematica now knows about the symbol f.
>>
>> f[x_] := Plot[x, {x, 0, 1}]
>> SetAttributes[f, Listable]
>> Clear[f]
>> ??f
>>
>> f[x_] := Plot[x, {x, 0, 1}]
>> SetAttributes[f, Listable]
>> ClearAll[f]
>> ??f
>>
>> f[x_] := Plot[x, {x, 0, 1}]
>> SetAttributes[f, Listable]
>> Remove[f]
>> ??f
>>
>> On 9/4/11 4:12 AM, AES wrote:
>>> In article<j3u7r6$a88$1@smc.vnet.net>,
>>> Murray Eisenberg<murray@math.umass.edu> wrote:
>>>
>>>> First, Clear, whether for a single object or an entire list of objects,
>>>> does not remove their Attributes, e.g., just their values. You might
>>>> want ClearAll instead.
>>>
>>> And how do either of those differ from Remove?
>>>
>>
>
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

[toc] | [prev] | [next] | [standalone]


#4784

FromAndrzej Kozlowski <akoz@mimuw.edu.pl>
Date2011-09-06 08:04 +0000
Message-ID<j44k61$94f$1@smc.vnet.net>
In reply to#4722
Doesn't really cripple f: try 

ClearAll[f]
f[x_] := Plot[x, {x, 0, 1}]; SetAttributes[f, Listable]
Remove[x]

then evaluate 

f[y]

Andrzej Kozlowski

On 5 Sep 2011, at 13:05, DrMajorBob wrote:

> Your experiment makes Remove look useful (possibly), but here's one that  
> does not:
> 
> ClearAll[f]
> f[x_] := Plot[x, {x, 0, 1}] SetAttributes[f, Listable]
> Remove[x]
> ?? f
> 
> Remove[x] cripples f without mentioning it, which I'd call a very ugly  
> side-effect.
> 
> Bobby
> 
> On Sun, 04 Sep 2011 17:05:26 -0500, Murray Eisenberg  
> <murray@math.umass.edu> wrote:
> 
>> Try the following little three-part experiment.  In each part, the last
>> step tells you what Mathematica now knows about the symbol f.
>> 
>>    f[x_] := Plot[x, {x, 0, 1}]
>>    SetAttributes[f, Listable]
>>    Clear[f]
>>    ??f
>> 
>>    f[x_] := Plot[x, {x, 0, 1}]
>>    SetAttributes[f, Listable]
>>    ClearAll[f]
>>    ??f
>> 
>>    f[x_] := Plot[x, {x, 0, 1}]
>>    SetAttributes[f, Listable]
>>    Remove[f]
>>    ??f
>> 
>> On 9/4/11 4:12 AM, AES wrote:
>>> In article<j3u7r6$a88$1@smc.vnet.net>,
>>>  Murray Eisenberg<murray@math.umass.edu>  wrote:
>>> 
>>>> First, Clear, whether for a single object or an entire list of objects,
>>>> does not remove their Attributes, e.g., just their values. You might
>>>> want ClearAll instead.
>>> 
>>> And how do either of those differ from Remove?
>>> 
>> 
> 
> 
> -- 
> DrMajorBob@yahoo.com
> 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web