Re: Re: Warning from Piecewise

*To*: mathgroup at smc.vnet.net*Subject*: [mg61673] Re: [mg61642] Re: Warning from Piecewise*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Tue, 25 Oct 2005 01:28:06 -0400 (EDT)*References*: <200510210438.AAA13446@smc.vnet.net> <djcgk3$6h0$1@smc.vnet.net> <200510250107.VAA16760@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

On 25 Oct 2005, at 10:07, albert wrote: > 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 > > No, of course,I agree with you and never meant anything else. I when I wrote that SetDelayed and Set are "special functions" I was actually referring to the fact that they evaluate their arguments in a "special way" (not relying on the "Evaluator" that evaluates arguments of functions without Hold attributes). Other built in functions also do that, for example Plot etc, though of course there are many different kinds of "special". Andrzej Kozlowski

**References**:**Warning from Piecewise***From:*Chris Rodgers <rodgers@physchem.NOSPAMox.aREMOVEc.uk>

**Re: Warning from Piecewise***From:*albert <awnl@arcor.de>