Functions and evaluation, returning themselves
- To: mathgroup at smc.vnet.net
- Subject: [mg7212] Functions and evaluation, returning themselves
- From: Red <red at nym.alias.net>
- Date: Fri, 16 May 1997 02:30:54 -0400 (EDT)
- Organization: mail2news@nym.alias.net
- Sender: owner-wri-mathgroup at wolfram.com
-----BEGIN PGP SIGNED MESSAGE----- I am trying to write a function in Mathematica that can give a message and return the expression entered. For example In[1] := Sin[] ``Sin::"argx": "Sin called with 0 arguments; 1 argument is expected. Out[1]= Sin[] (There is no HoldForm around this output) To do this I tried to make definitions like f[] := (Message[f::argx]; Return @ Unevaluated @ f[]) But the Out is Unevaluated[f[]] instead of f[] or f[] := (Message[f::argx]; Unevaluated @ f[]) which gives infinite recursion. I tried some definitions that change $Line or DownValues[Out]. f[] := (Message[f::argx]; l = $Line; $Line = Infinity; Unprotect[Out]; Out[l] := f[]; Protect[Out]; $Line = l+1) If you know how to write a function that acts like Sin above then please help. - ----------- finger:red at nym.alias.net -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBM3i8Vbcaab4ltFhVAQHYNgP8D9dGsDBwL3ikruifff8xVZr9czX6nc4L bCsZeErDDcdGCHmSCtTgpguJSMAmDe1lM/mB0TErzW78JSd7i/cshJsYjpXYbiLd DyearYmI/ZQ3x5Wyltz+rMwAHyjEd6sc7PUgtA4nyeoqtpF379/vuzA+vQyYy8rw jbjkTOzA0UE= =/jws -----END PGP SIGNATURE-----