4
$\begingroup$

In this answer Carl Woll uses the ParentList symbol to inherit old input aliases when adding a new one:

CurrentValue[EvaluationNotebook[], 
   InputAliases] = {"0x" -> 
    RowBox[{InterpretationBox[
       StyleBox["\"0\"", ShowStringCharacters -> False], 
       Function[Null, 
        FromDigits[StringDrop[ToString@Unevaluated@#, 1], 16], 
        HoldAll]], "\[InvisibleApplication]", "\[InvisibleSpace]", 
      StyleBox["x", ShowAutoStyles -> False]}], ParentList};
CurrentValue[EvaluationNotebook[], InputAliases] /. Rule[a_, _] :> a

{"0x", ParentList}

And we can still use the all the basic built-in aliases

On the other-hand, we can get the same result using Inherited:

CurrentValue[EvaluationNotebook[], InputAliases] = Inherited;
CurrentValue[EvaluationNotebook[], 
   InputAliases] = {"0x" -> 
    RowBox[{InterpretationBox[
       StyleBox["\"0\"", ShowStringCharacters -> False], 
       Function[Null, 
        FromDigits[StringDrop[ToString@Unevaluated@#, 1], 16], 
        HoldAll]], "\[InvisibleApplication]", "\[InvisibleSpace]", 
      StyleBox["x", ShowAutoStyles -> False]}], Inherited};
CurrentValue[EvaluationNotebook[], InputAliases] /. Rule[a_, _] :> a

{"0x", Inherited}

And we can, again, use the all of the built-in aliases, but if we look at the AbsoluteCurrentValues for the first case:

CurrentValue[EvaluationNotebook[], 
   InputAliases] = {"0x" -> 
    RowBox[{InterpretationBox[
       StyleBox["\"0\"", ShowStringCharacters -> False], 
       Function[Null, 
        FromDigits[StringDrop[ToString@Unevaluated@#, 1], 16], 
        HoldAll]], "\[InvisibleApplication]", "\[InvisibleSpace]", 
      StyleBox["x", ShowAutoStyles -> False]}], ParentList};
AbsoluteCurrentValue[EvaluationNotebook[], InputAliases] /. 
 Rule[a_, _] :> a

{"0x", "intt", "dintt", "sumt", "prodt", "dt", "ia", "cbrt", "surd", \
"ket", "bra", "braket", "delay", "grad", "del.", "delx", "del2", \
"notation", "notation>", "notation<", "symb", "infixnotation", \
"addia", "pattwraper", "madeboxeswraper"}

And the second:

CurrentValue[EvaluationNotebook[], InputAliases] = Inherited;
CurrentValue[EvaluationNotebook[], 
   InputAliases] = {"0x" -> 
    RowBox[{InterpretationBox[
       StyleBox["\"0\"", ShowStringCharacters -> False], 
       Function[Null, 
        FromDigits[StringDrop[ToString@Unevaluated@#, 1], 16], 
        HoldAll]], "\[InvisibleApplication]", "\[InvisibleSpace]", 
      StyleBox["x", ShowAutoStyles -> False]}], Inherited};
AbsoluteCurrentValue[EvaluationNotebook[], InputAliases] /. 
 Rule[a_, _] :> a

{"0x", Inherited}

We see that even though they are operationally similar, the AbsoluteCurrentValue result is different.

So I guess my question is, how do ParentList and Inherited differ outside of this small difference?

ParentList is obviously more scoped to list-type constructs, but why does it need to exist at all?


Extra Info:

Per Albert Retey's comment I checked whether either responded differently to upstream changes:

StyleSheetEdit["MyStyle1" -> "Input",
  {
   InputAliases -> {"0x" -> "\"\[SadSmiley]\"", ParentList}
   },
  "MakeCell" -> True
  ];
CellPrint[Cell[BoxData[""], "MyStyle1"]];
StyleSheetEdit["MyStyle2" -> "Input",
  {
   InputAliases -> {"0x" -> "\"\[SadSmiley]\"", Inherited}
   },
  "MakeCell" -> True
  ];
CellPrint[Cell[BoxData[""], "MyStyle2"]];
CurrentValue[EvaluationNotebook[], InputAliases] = {"a" -> "\"b\""};

Both cells behaved entirely the same

$\endgroup$
  • $\begingroup$ What happens when you change the parent? I woud expect Inherited to reflect those changes but the explicit values that ParentList was creating would not change. Just guessing... $\endgroup$ – Albert Retey Dec 9 '17 at 19:44
  • $\begingroup$ @AlbertRetey nope. Both seem to inherit fine. $\endgroup$ – b3m2a1 Dec 9 '17 at 20:05
  • $\begingroup$ ok, good to know :-) $\endgroup$ – Albert Retey Dec 9 '17 at 20:10
5
$\begingroup$

Its name is misleading, unfortunately, because it can be very useful.

A better name would be something around ParentSequence/ParentArguments. Here is one example:

CurrentValue[EvaluationNotebook[], TaggingRules] = {"old" -> "value"};
cell = EvaluationCell[];

CurrentValue[cell, TaggingRules] = {ParentList, "new" -> "value"};
AbsoluteCurrentValue[cell, TaggingRules]
{"old" -> "value", "new" -> "value"}
CurrentValue[cell, TaggingRules] = {Inherited, "new" -> "value"};
AbsoluteCurrentValue[cell, TaggingRules]
{{"old" -> "value"}, "new" -> "value"}

So in this case you really want to use it.

$\endgroup$
  • $\begingroup$ Fantastic! I can think of so many situations where that would have made my life so much simpler. $\endgroup$ – b3m2a1 Dec 9 '17 at 23:25
  • $\begingroup$ @b3m2a1 There are exceptions though CurrentValue[EvaluationCell[], ContextMenu] = {MenuItem["test", "test"], ParentList}, I am not sure why. And sometimes Inherited is handled gracefully anyway, probably when nested list does not make sense. $\endgroup$ – Kuba Dec 9 '17 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.