Re: Evaluation rules and HoldRest
- To: mathgroup at smc.vnet.net
- Subject: [mg42659] Re: [mg42613] Evaluation rules and HoldRest
- From: William K Reinholtz <kirk.reinholtz at jpl.nasa.gov>
- Date: Sat, 19 Jul 2003 03:19:43 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I think your problem is the Evaluate[...]. If[] tries to not evaluate it's args, bu you forced them to evaluate anyway. If you don't do the evaluate, it'll do as you wish. On Friday, Jul 18, 2003, at 02:25 US/Pacific, Matthias wrote: > Hello, > > why is this not working as intended? > > === > Assert[bool_, failedExpr_] := If[! bool, Evaluate[failedExpr]]; > SetAttributes[Assert, HoldRest]; > Assert[1 == 1, Print["Assertion violated!"]]; > === > > The code above prints "Assertion violated". I know that the code > behaves > correctly when replacing ":=" by "=". I'd like to understand why and > would > appreciate any explanation, or pointer to relevant documentation. > > Thanks in advance, > > Matthias >