MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Locked In Block

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20233] Re: [mg20206] Locked In Block
  • From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
  • Date: Fri, 8 Oct 1999 18:30:12 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

I think the issue is fairly simple. Block temporarily clears not only the 
value but also the Attributes of a symbol. Here is an example:
In[1]:=
SetAttributes[v, HoldAll]
In[2]:=
Attributes[v]
Out[2]=
{HoldAll}
In[3]:=
Block[{v}, Attributes[v]]
Out[3]=
{}

Once you give v the Locked attribute it can't be cleared anymore hence using
Block fails. It has to be admitted that the message you get is less than
enlightening
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp


----------
>From: dreiss at !SPAMearthlink.net (David Reiss)
>To: mathgroup at smc.vnet.net
>Subject: [mg20233] [mg20206] Locked In Block
>Date: Thu, Oct 7, 1999, 10:06
>

> What is the reason for this behavior? I make a
> locked variable, z,  and wish to use it within
> a Block construct as in the simple example that
> follows. According to the usage message for
> Locked, the Attributes for z cannot be changed
> once it has been given the Locked attribute.
>
> In[1]:=
> ?Locked
>
> "Locked is an attribute which, once assigned, prevents
> modification of any attributes of a symbol."
>
> In[2]:=
> SetAttributes[z, Locked]
>
> Now give z a value.
>
>
> In[3]:=
> z = 9
>
> Out[3]=
> 9
>
> So this is what z is thus far:
>
>
> In[4]:=
> ?z
>
> "Global`z"
>
> Attributes[z] = {Locked}
> z = 9
>
>
>
> Now I try to localize z to a different value
> within Block, but it returns unevaluated with
> an error message.
>
>
> In[5]:=
> Block[{z = 2}, z]
>
> Out[5]=
> Block[{z = 2}, z]
>
> Block::"lockt": "Cannot localize locked symbol z
> in assignment z = 2 from local variable specification
> {z = 2}.
>
>
>
> So a possible question is "where within the execution of
> Block is there an attempt to change the attributes of z?"
> Perhaps though the issue is more (or less!) subtle than this.
>
>
>
> )--------------------------------------
> )        Scientific Arts:
> ) Creative Services and Consultation
> ) for the Applied and Pure Sciences
> )
> )   http://www.scientificarts.com
> )
> ) David Reiss
> ) Email: dreiss at !SPAMscientificarts.com
> ) [Remove the !SPAM to send email]
> )-----------------------------------
> 


  • Prev by Date: Re: Surface of Revolution
  • Next by Date: Crash course in Mathematica syntax reqd
  • Previous by thread: Re: Re: Replacing Part of a Matrix
  • Next by thread: Crash course in Mathematica syntax reqd