MathGroup Archive 2005

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

Search the Archive

Re: Warning from Piecewise

  • To: mathgroup at
  • Subject: [mg61642] Re: Warning from Piecewise
  • From: albert <awnl at>
  • Date: Mon, 24 Oct 2005 21:07:00 -0400 (EDT)
  • References: <> <djcgk3$6h0$>
  • Sender: owner-wri-mathgroup at


> 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},
      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).


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

or am I missing your point?


  • 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