MathGroup Archive 2005

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

Search the Archive

Re: Warning from Piecewise

  • To: mathgroup at smc.vnet.net
  • Subject: [mg61642] Re: Warning from Piecewise
  • From: albert <awnl at arcor.de>
  • Date: Mon, 24 Oct 2005 21:07:00 -0400 (EDT)
  • References: <200510210438.AAA13446@smc.vnet.net> <djcgk3$6h0$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

> Actually Set and SetDelayed are special functions and their behaviour
> in this sort of situation is not determined by their attributes. You
> can see the difference as follows. First, let us create a function H,
> to which we give the Attribute HoldAll.

I absolutely agree that Set and SetDelayed are special functions, but to
understand the behaviour in regard to the "partial" evaluation I think they
are not so special at all. Any function that has the Attribute HoldAll can
extract parts of the unevaluated expressions an evaluate just these parts.
Look at the following example:

SetAttributes[evaluatepartssometimes, HoldAll]

evaluatepartssometimes[x_, val_] := Module[{head, args},
    Switch[Head[Unevaluated[x]],
      Symbol, {Hold[x],{}, Hold[val]},
      _,
      head = Extract[Unevaluated[x], 0, Hold];
      args = Extract[Unevaluated[x], #] & /@ Range[Length[Unevaluated[x]]];
      
      {head, args, Hold[val]}
      ]
    ]

this should behave very similar to SetDelayed concerning the evaluation of
it's first argument (although I don't know the exact rules of evaluation
for SetDelayed).

e.g.:

a=1
evaluatepartssometimes[a[Print["hello"]; 1 + 1, 3 - 4], 1 + 4]
evaluatepartssometimes[a, 1 + 4]

or am I missing your point?

albert


  • Prev by Date: Re: 'Raw Expressions'
  • Next by Date: Re: 'Raw Expressions'
  • Previous by thread: Re: Warning from Piecewise
  • Next by thread: Re: Re: Warning from Piecewise