Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Mathematica daily WTF (101221T)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114897] Mathematica daily WTF (101221T)
  • From: kj <no.email at please.post>
  • Date: Wed, 22 Dec 2010 02:34:25 -0500 (EST)

Today's daily wonder comes from an innocent attempt to define a
home-grown version of Sequence:

In[1]:= sequence /: w_[x___, sequence[y___], z___] := w[x, y, z];


It seems to work:

In[2]:= foo[1, 2, sequence[3, 4, 5], 6, 7] === 
 foo[1, 2, Sequence[3, 4, 5], 6, 7]

Out[2]= True


But, when evaluated by itself, it causes the Mathematica output
procedure to spill its guts in a most undignified fashion:

In[3]:= sequence[3, 4, 5]

During evaluation of In[3]:= If::argb: If called with 8 arguments; between 2 and 4 arguments are expected. >>

Out[3]= If[False, 3, 4, 5, 
 With[{OutputSizeLimit`Dump`boxes$ = 
    Block[{$RecursionLimit = Typeset`$RecursionLimit}, 
     MakeBoxes[sequence[3, 4, 5], StandardForm]]}, 
  OutputSizeLimit`Dump`loadSizeCountRules[]; 
  If[TrueQ[BoxForm`SizeCount[OutputSizeLimit`Dump`boxes$, 1048576]], 
   OutputSizeLimit`Dump`boxes$, 
   OutputSizeLimit`Dump`encapsulateOutput[
    sequence[3, 4, 5], $Line, $SessionID, 5]]], 3, 4, 5]


Ironically, the idea for trying out this self-rolled implementation
of sequence as a "universal up-value" comes from a passing remark
by Robby Villegas in an article (http://is.gd/j8V9f) where he
introduces such "universal up-values" as an example for why MakeBoxes
(see Out[3] above) needs to be so "nasty".  Point taken, but clearly,
there's a leak, at least in version 7.

(I hope that someone at Wolfram is making note of reports like this
one, since, as far as I can tell, there's no public bug report page
for Mathematica.)

~kj


  • Prev by Date: Re: Complete uninstall of Mathematica 6/7/8 on a Mac
  • Next by Date: Re: Complete uninstall of Mathematica 6/7/8 on a Mac
  • Previous by thread: Re: what's wrong with this?!!
  • Next by thread: Re: Mathematica daily WTF (101221T)