MathGroup Archive 2007

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

Search the Archive

Re: Re: Sequence as a universal UpValue

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74653] Re: [mg74632] Re: Sequence as a universal UpValue
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Thu, 29 Mar 2007 05:33:25 -0500 (EST)
  • References: <euan47$dni$1@smc.vnet.net> <200703290729.CAA07586@smc.vnet.net>

I would guess that the last two bullet points in the list of A.4.1 are
not true. I believe that built in DownValues (which may be hidden by
the attribute ReadProtected) and user supplied DownValues are actually
part of the same list of DownValues. However, user supplied DownValues
are probably more specific than the built in DownValues, which may
lead to their higher transformation precedence.

On 3/29/07, Szabolcs <szhorvat at gmail.com> wrote:
> On Mar 27, 11:11 am, "Chris Chiasson" <chris at chiasson.name> wrote:
> > In his presentation on working with held expressions at
> >
> > http://library.wolfram.com/conferences/devconf99/villegas/Unevaluated...
> >
> > Villegas says:
> >
> > "In fact, Sequence itself could almost be implemented as a universal
> > UpValue (maybe Dave Withoff or Roman Maeder remembers if that's not
> > quite true)."
> >
> > So, I am wondering, does the following input disprove that Sequence
> > can be implemented as a universal UpValue? How should I think of
> > Sequence? Importantly, why doesn't blocking Sequence work like
> > blocking the arbitrary symbol?
>
> I'm not sure I understand completely how these things work, but the
> behaviour of Block does seem to make sense if you read its help page.
> It says:
>
> " When you execute a block, values assigned to x, y, ... are cleared.
> When the execution of the block is finished, the original values of
> these symbols are restored. "
>
> When you put blahblah in a Block, the definitions associated with it
> are cleared, and
> its arguments are not spliced into Map. You get the expected result.
>
> But the definitions associated with Sequence are built-in, so they can
> not be cleared.
>
> ...
>
> Hmm ... Now that I experimented some more, Sequence does seem to be
> special in this respect:
>
> In[1]:=
> Block[{},Print[f/@{a,b}]]
> Block[{Map},Print[f/@{a,b}]]
>
> >From In[1]:=
> {f[a],f[b]}
>
> >From In[1]:=
> f/@{a,b}
>
> So built-in definitions can be cleared after all. But the Mathematica
> book does mention that Sequence is treated in a special way (unlike
> other built-ins). Check Section A.4.1 (Mathematica Reference Guide ->
> Evaluation -> The Standard Evaluation Sequence).
>
>
> >
> > In[1]:=
> > blahblah/:h_[l___,blahblah[blahblahArgs___],r___]=h[l,blahblahArgs,r]
> >
> > UpValues@blahblah
> >
> > a[1,blahblah[2,3]]
> >
> > Block[{Sequence},f/@Sequence[1,2,3]]
> >
> > Block[{blahblah},f/@blahblah[1,2,3]]
> >
> > Out[1]=
> > h[l,blahblahArgs,r]
> >
> > Out[2]=
> > {HoldPattern[h_[l___,blahblah[blahblahArgs___],r___]]\[RuleDelayed]
> >     h[l,blahblahArgs,r]}
> >
> > Out[3]=
> > a[1,2,3]
> >
> > Map::nonopt: Options expected (instead of 3) beyond position 3 in
> > Map[f,1,2,3]. An option must be a rule or a list of rules.
> >
> > Out[4]=
> >
> > Map[f,1,2,3]
> >
> > Out[5]=
> > blahblah[f[1],f[2],f[3]]
> >
> > Thanks for your input,
> >
> > --http://chris.chiasson.name/
>
>
>
>


-- 
http://chris.chiasson.name/


  • Prev by Date: Re: Re: Sequence as a universal UpValue
  • Next by Date: Re: Re: Multi-core Support in Mathematica 5.2
  • Previous by thread: Re: Re: Sequence as a universal UpValue
  • Next by thread: Is this a problem in mathematica?