Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Overloading StringJoin

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109799] Re: Overloading StringJoin
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 18 May 2010 02:02:16 -0400 (EDT)

On 5/17/10 at 7:12 AM, madler at alumni.caltech.edu (Mark Adler) wrote:

>I use Join enough that I like to overload StringJoin to do it:

>Unprotect[StringJoin]; x_List <> y_List := x~Join~y
>Protect[StringJoin];

>Then I can do this:

>{1, 2} <> {3, 4} {1, 2, 3, 4}

>Why doesn't Mathematica already do this?  It seem like an obvious
>use of <>.  Or is there a good reason that they don't do this, and
>therefore if I do, it makes me a bad person?

I've no idea why this functionality isn't built-in nor does it
make you a bad person to overload StringJoin this way. But,
there is some level of risk in overloading built-in functions of
Mathematica. There maybe unwanted side effects. So, I would use
one of the built-in operators which do not have any defined
functionality instead of <>. For example, there is CirclePlus
which can be entered as esc c + esc. This would ensure there is
no possibility of unwanted side effects.



  • Prev by Date: Re: Overloading StringJoin
  • Next by Date: Re: Overloading StringJoin
  • Previous by thread: Re: Overloading StringJoin
  • Next by thread: Re: Overloading StringJoin