MathGroup Archive 1998

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

Search the Archive

Re: operator overloading with UpValues (eg, for shifting graphics)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13637] Re: operator overloading with UpValues (eg, for shifting graphics)
  • From: "Allan Hayes" <hay at haystack.demon.cc.uk>
  • Date: Fri, 7 Aug 1998 08:41:19 +0100
  • References: <6qbqkd$a67@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Daniel,

>should the Listable-ness of
>Plus have precedence over my UpValue for Line?

Yes: attributes are used before rules. This is standard in the
evaluation process.
Leaving aside issues arrising from holding attributes we get (where x* =
value of x)

f[a,b,..] -> f*[a*,b*,..] -- (if f ia Flat use this) --> (if f ia
Listable use this) --> ...

Allan


------------------------------------------------------------- 
Allan Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642


****************

Daniel Reeves wrote in message <6qbqkd$a67 at smc.vnet.net>...
>I thought it would be nice to shift some graphics by just adding an x-y
>pair.  It seemed like this sort of thing should do that:
>
>Unprotect[Line];
>Line /: Line[pts_] + {x_,y_} := Line[pts+{x,y}] Protect[Line];
>
>But it doesn't.  The UpValue for Graphics doesn't get used. This does
>work:
>
>Line /: Line[pts_] + shift[x_,y_] := Line[pts+{x,y}]
>
>but then I might as well just do this:
>
>shift[Line[pts_],{x_,y_}] := Line[pts+{x,y}]
>
>The idea is to be able to just say Line[...] + {x,y} and get a shifted
>Line.
>
>Does anyone know a way to do that?
>Also, if/why Mathematica is doing "the right thing" in defying my
>expectations in the first example.  Ie, should the Listable-ness of
>Plus have precedence over my UpValue for Line?
>
>Thanks,
>Daniel
>
>--
>Daniel Reeves  dreeves at umich.edu
>http://ai.eecs.umich.edu/people/dreeves
>
>"This isn't right.  This isn't even wrong."
>  -- Wolfgang Pauli, on a paper submitted by a physicist colleague
>
>



  • Prev by Date: Re: What is the fastest machine for Mathematica?
  • Next by Date: Solve Equations over Finite Group
  • Previous by thread: operator overloading with UpValues (eg, for shifting graphics)
  • Next by thread: Re: operator overloading with UpValues (eg, for shifting graphics)