How is a~b
parsed and evaluated? I would expect an error, but it goes through without any complaints, yielding no apparent output. At first I thought it evaluated to Null
, but then I realized every expression I've tried containing a~b
(either directly or through something like %
) gives no output whatsoever. Consider the following:
a~b
a~b//FullForm
Trace[a~b]
{A, a~b, B}
(a~b)~c
Each of the above (even input in separate cells) gives no output whatsoever.
Context: I accidentally typed A ~f[##,...]&~ B
and was surprised by the result. (To be clear, I understand the precedence issue; what's surprising to me is the handling of (A~f[##,...])&
.)
Edit 2
Thanks to Carl Woll (and later Szabolcs), I now know for sure that a~b
is a syntax error. But my true problem was this: the front end didn't tell me it was a syntax error.
At Carl Woll's urging, I realized Messages[Syntax]
returned
{HoldPattern[Syntax::bktwrn]:>"`1`" represents multiplication; use "`2`" to represent a function`4`.}
rather than the expected
{HoldPattern[Syntax::bktwrn]:>"`1`" represents multiplication; use "`2`" to represent a function`4`.,
HoldPattern[Syntax::tsntxi]:>"`1`" is incomplete; more input is needed.`4`}
I.e., Syntax::tsntxi
was nowhere to be found!
Later I realized that in a fresh kernel, a~b
is properly recognized as a syntax error. Before I restarted the kernel, I noticed something interesting: even Plot[x]
failed to give me Plot::argr
(Plot called with 1 argument; 2 arguments are expected
) warning.
Reevaluating the notebook does not reproduce the error. There must have been some funny business somewhere in the session that later got erased. This is fortunate, as my problem is effectively resolved, even if my curiosity isn't.
It seems that somewhere in the (long) notebook I was working in, MMA stopped showing me certain messages, and stopped recognizing certain syntax errors. Without access to the session, it's nigh impossible to say more.
Lastly I offer an apology, for had I simply tested a~b
in a fresh kernel, I wouldn't have wasted everyone's time trying to figure out the true problem. I sincerely thank everyone who viewed and thought about my problem, especially Carl Woll. At the very least, I learned some things about how MMA handles syntax errors in the process. (This is why I will accept Carl Woll's answer.) Of course, I also learned my lesson: always test in a fresh kernel!
Edit 1
At Carl Woll's request, here's raw call data:
Cell[BoxData[
RowBox[{"a", "~", "b"}]], "Input",
CellChangeTimes->{{3.69637095440485*^9, 3.6963709556847563`*^9}}]
And here's the output of CurrentValue[{StyleDefinitions, "Input"}]
{CellMargins -> {{66, 10}, {5, 10}},
StyleKeyMapping -> {"=" -> "WolframAlphaShort", "*" -> "Item"},
Evaluatable -> True, CellGroupingRules -> "InputGrouping",
TextClipboardType -> "InputText", StripStyleOnPaste -> True,
PageBreakWithin -> False, GroupPageBreakWithin -> False,
DefaultFormatType -> DefaultInputFormatType,
ContextMenu -> {MenuItem["Cu&t", "Cut"], MenuItem["&Copy", "Copy"],
MenuItem["&Paste", FrontEnd`Paste[After]],
Menu["Cop&y As", {MenuItem["Plain &Text",
FrontEnd`CopySpecial["PlainText"]],
MenuItem["&Input Text", FrontEnd`CopySpecial["InputText"]],
MenuItem["&LaTeX",
KernelExecute[ToExpression["FrontEnd`CopyAsTeX[]"]],
MenuEvaluator -> Automatic],
MenuItem["M&athML",
KernelExecute[ToExpression["FrontEnd`CopyAsMathML[]"]],
MenuEvaluator -> Automatic], Delimiter,
MenuItem["&Cell Expression",
FrontEnd`CopySpecial["CellExpression"]],
MenuItem["&Notebook Expression",
FrontEnd`CopySpecial["NotebookExpression"]]}], Delimiter,
MenuItem["&Evaluate Cell", "EvaluateCells"],
MenuItem["Evaluate &in Place", All],
MenuItem["Evaluate Initiali&zation Cells",
"EvaluateInitialization"],
Menu["C&onvert To", {MenuItem["&InputForm",
"SelectionConvert" -> InputForm],
MenuItem["&Raw InputForm", "SelectionConvert" -> RawInputForm],
MenuItem["&OutputForm", "SelectionConvert" -> OutputForm],
MenuItem["First Convert to BoxForm",
"MenuListConvertFormatTypes", MenuAnchor -> True]}], Delimiter,
MenuItem["Make &Hyperlink...", "CreateHyperlinkDialog"],
MenuItem["Insert Table/&Matrix...", "CreateGridBoxDialog"],
MenuItem["Insert &Special Character...",
FrontEndExecute[{FrontEnd`NotebookOpen["SpecialCharacters.nb"]}]],
Delimiter, MenuItem["Check &Balance", "Balance"],
MenuItem["Di&vide Cell", "CellSplit"],
MenuItem["&Un/Comment",
KernelExecute[ToExpression["FE`toggleComment[]"]],
MenuEvaluator -> Automatic], Delimiter,
MenuItem["&Get Help", FrontEnd`SelectionHelpDialog[True]],
MenuItem["Why the Coloring?...",
FrontEndExecute[{FrontEnd`NotebookOpen[
FrontEnd`FindFileOnPath["WhyTheColoring.nb",
"PrivatePathsSystemResources"]]}]],
MenuItem["Spea&k Selection", "SelectionSpeak"], Delimiter,
MenuItem["Toggle &Full Screen",
FrontEndExecute[
FrontEnd`Value[FEPrivate`NotebookToggleFullScreen[]]]]},
ShowAutoStyles -> True, ShowAutoConvert -> True,
"TranslationOptionsContentEnabled" -> Automatic,
"HyphenationOptionsHyphenationCharacter" -> "\[Continuation]",
AutoItalicWords -> {}, AutoQuoteCharacters -> {},
PasteAutoQuoteCharacters -> {}, LanguageCategory -> "Input",
FormatType -> InputForm, NumberMarks -> True,
LinebreakAdjustments -> {0.85, 2, 10, 0, 1},
CounterIncrements -> "Input", MenuSortingValue -> 1500,
MenuCommandKey -> "9", FontSize -> 13, FontWeight -> "DemiBold"}