6

Bug introduced in 10.0 and fixed in 11.0.0


With

Hold[Dataset[Random[]]]

enter image description here

instead of an expected

Hold[Dataset[Random[]]]

Can Dataset expressions be held?

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
Ronald Monson
  • 6,076
  • 26
  • 46
  • Related http://mathematica.stackexchange.com/questions/78131/why-can-i-not-replace-a-dataset-using-a-rule and Dataset upvalues but I wasn't able to customize. – Ronald Monson Jul 15 '15 at 02:17
  • Current use case is generating some documentation that uses held WL commands but can imagine future needs requiring the passing around of Held Datasets as per the holding of all other WL expressions. – Ronald Monson Jul 15 '15 at 02:46
  • 4
    Hold stops evaluation, but not typesetting (FormatValues). – ilian Jul 15 '15 at 02:49
  • @ilian in terms of evaluation ls = {}; held = Hold@Dataset[AppendTo[ls, Random[]]]; SetAttributes[f, HoldAll]; f[x_] := x; f@held produces three random numbers instead of one random number? in terms of an appearance as a WL command, is there a way of outputting Dataset[{assocs}], verbatim - initial attempts at redefining Dataset output via Format as suggested proved unsuccessful and also seems like overkill ... – Ronald Monson Jul 15 '15 at 03:41
  • 1
    Yes, it looks like there is an evaluation leak in the typesetting. Note that FullForm[f @ held] is as expected. Would perhaps something like Inactivate[Dataset[{Random[], Random[]}], Random] work? – ilian Jul 15 '15 at 04:13
  • Same thing happens with Graphics for the reason given by ilian. Has been a feature of Mathematica since V6 at least. – m_goldberg Jul 15 '15 at 04:19
  • @m_goldberg Ok, but feature? ... I can't think of a use-case for this default Hold behaviour? – Ronald Monson Jul 15 '15 at 06:56
  • @ilian yes FullForm holds and nearly works but then requires some kind of bootstrapping to rise above e.g. FullForm@HoldForm[Dataset[Random[]]] still shows the HoldForm. Be nice if the default behaviour was changed. Thanks. – Ronald Monson Jul 15 '15 at 07:05

1 Answers1

7

This question is related to:

My proposed solution:

mk : MakeBoxes[(Hold | HoldForm | HoldComplete | HoldPattern)[__], _] := 
 Block[{$hldDataset = True, Dataset}, mk] /; ! TrueQ[$hldDataset]

Now:

Hold[Dataset[Random[]]]
Hold[Dataset[Random[]]]

Unlike the case of Graphics I consider the default formatting behavior pathological here.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371