RE: Re: Manipulating Slot objects in Compile

*To*: mathgroup at smc.vnet.net*Subject*: [mg24687] RE: [mg24604] Re: Manipulating Slot objects in Compile*From*: Wolf Hartmut <hwolf at debis.com>*Date*: Fri, 4 Aug 2000 01:19:09 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

my answer interspersed at [Hartmut Wolf] > -----Original Message----- > From: Jens-Peer Kuska [SMTP:kuska at informatik.uni-leipzig.de] To: mathgroup at smc.vnet.net > Sent: Tuesday, August 01, 2000 1:15 PM > To: Wolf Hartmut > Cc: mathgroup at smc.vnet.net > Subject: Re: [mg24604] Re: Manipulating Slot objects in Compile > > Hello, > > > first of all there should be parenthesis arround the replacements > > c = Compile @@ ({{{cArg, _Real, 1}}, Hold @@ {grad /. rules}} /. > Hold[a_Part] :> a /. Hold[a_] :> Unevaluated[a]) > > c[[3]] > > {0, 4, 11, 0, 2} > > > and > > c[{2, 3}] > > {108., 108.} > > the parenthesis are lost while collecting the steps. :-( > But my original answer had a assigment step. > [Hartmut Wolf] Sorry, Jens, I should have seen that! > Here is my first reply: > > >> [Hartmut Wolf] -- I omit it here, it's published -- > >> > > Your solution must explicit switch off the > error messages of Part[cArg,i]. > One task was just to avoid the explicit Off[Part::"partd"] > because there is no save way to switch it on again. > Since there is no way to find out if the message was prevoiusly on or > off, > you cant just say On[Part::"partd"]. That's why my solution > was not so simple as yours. > [Hartmut Wolf] There is a way to do that, regard: In[7]:= Clear[cArg] In[8]:= On[Part::"partd"] In[9]:= wasOn = Check[cArg[[1]]; False, True, Part::"partd"] >From In[9]:= Part::"partd": "Part specification \!\(cArg \[LeftDoubleBracket] 1 \ \[RightDoubleBracket]\) is longer than depth of object." Out[9]= True In[10]:= Off[Part::"partd"] In[11]:= Check[cArg[[1]]; False, True, Part::"partd"] Out[11]= False In[12]:= If[wasOn, On[Part::"partd"]] In[13]:= Check[cArg[[1]]; False, True, Part::"partd"] >From In[13]:= Part::"partd": "Part specification \!\(cArg \[LeftDoubleBracket] 1 \ \[RightDoubleBracket]\) is longer than depth of object." Out[13]= True Kind regards, Hartmut