MathGroup Archive 2006

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

Search the Archive

Re: HoldFirst question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65535] Re: HoldFirst question
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Thu, 6 Apr 2006 06:52:59 -0400 (EDT)
  • References: <e10901$lio$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Yaroslav Bulatov wrote:
> f=5;f[a_]=a gives an error because it evaluates f[a_] to 5[a_]
> 
> But Set is HoldFirst, doesn't that mean that f[a_] will be held
> unevaluated?
> 
Bear in mind that a HoldFirst function can evaluate its argument - it is 
just that this does not happen automatically. It is easy to write such a 
function yourself:

SetAttributes[ff,HoldFirst];
ff[x_]:=(Print[HoldForm[x],"=",x];x)

Set clearly evaluates the Head of the lhs.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: HoldFirst confusion
  • Next by Date: Re: Count Function
  • Previous by thread: Re: HoldFirst question
  • Next by thread: Re: HoldFirst question