Re: Mathematica daily WTF (101221T)

*To*: mathgroup at smc.vnet.net*Subject*: [mg114925] Re: Mathematica daily WTF (101221T)*From*: John Fultz <jfultz at wolfram.com>*Date*: Thu, 23 Dec 2010 03:52:30 -0500 (EST)*Reply-to*: jfultz at wolfram.com

This comes from the code which performs this magic... In[1]:= Range[10^6] Out[1]= (* A very large output was generated. Here is a sample of it: .... *) which works fine with Sequence[], but not with your home-grown version. Since Mathematica is so completely general, and since so much of Mathematica is written in Mathematica itself, it's nearly always going to be possible to defeat internal implementation with externally applied grotesquery (as, for example, another person on this forum did recently by redefining StringJoin in a way that didn't correctly handle all possible inputs). Sometimes that amounts to a bug, and sometimes it amounts to abuse. In this case, I suspect it's a bug, although I haven't thought deeply about it and reserve the right to change my mind. The page for reporting bugs in Mathematica is here: http://www.wolfram.com/support/contact/email/?topic=Feedback Sincerely, John Fultz jfultz at wolfram.com User Interface Group Wolfram Research, Inc. On Wed, 22 Dec 2010 02:34:25 -0500 (EST), kj wrote: > 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