|
[Date Index]
[Thread Index]
[Author Index]
Re: UpValues for expressions headed by a string
- To: mathgroup at smc.vnet.net
- Subject: [mg62941] Re: [mg62896] UpValues for expressions headed by a string
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Fri, 9 Dec 2005 05:10:22 -0500 (EST)
- References: <200512080504.AAA11663@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Dec 8, 2005, at 12:04 AM, Trevor Baca wrote:
> First question: is it possible to assign an upvalue to a string?
No
> Second question: why doesn't unprotecting String with
>
> Unprotect[String];
> "bar" /: wiggle[b_"bar"?barQ] := First[b] - 5;
> Protect[String]
>
> work?
Because TagSetDelayed wants a symbol as its first argument and "bar"
is not a symbol it's a string.
> Last, is it, in general, a bad idea to create data types headed with a
> string, either because of situations like the one given here or for
> some other, additional reasons?
I'm not sure what advantage having a head that's a string confers.
If you are getting your heads from a set of strings, as long as they
don't evaluate to some other type than symbol just use ToExpression
and ToString to use it as a symbol where necessary and a string where
that's the appropriate interpretation.
As you can see the pattern matcher prefers to work with things that
are symbols so if you are planning on manipulating your heads you
sacrifice a lot of built in functionality by not leaving them as
symbols.
Regards,
Ssezi
Prev by Date:
Re: FixedPoint stops "when elements no longer change"?
Next by Date:
Evaluate[] not needed in With[]
Previous by thread:
UpValues for expressions headed by a string
Next by thread:
Re: UpValues for expressions headed by a string
|