Implicit multiplication in text mode
I keep wanting to use implicit multiplication in Text Mode.
IIRC, the original reasons why not were:
- If
x yis supported forx*y, then it would seem likexymight be supported, but that's a two-letter variable instead of multiplying x and y. - Problem with knowing when one line ends and the next line starts.
(2) is fixed now since it's clear with double-newline (or semicolon). (and was always a problem even without implicit multipication, e.g. a line y=f followed by a line (x+1)^2 could be parsed as y=f(x+1)^2)
(1) could be worked around by disallowing implicit identifier times identifier.
It would still be hugely beneficial to allow implicit multiplication for everything besides identifier times identifier:
y = x { x > 3 }would worky = 2x^2 + 5x + 3would work(1,2,3) twould work
Note cross would be a keyword once implemented. So y = (1,2,3) cross (4,5,6) would not be parsed like y = (1,2,3) * cross * (4,5,6)
(1) could be worked around by disallowing implicit identifier times identifier.
My main concern with this would be people inadvertently trying to do identifier times identifier and accidentally making a larger, compound identifier. In theory, this could be mitigated by recognizing that an identifier doesn't exist and seeing if it can be split apart into smaller identifiers that can be multiplied together, and then showing a specific error message if it can.
The worst case, though, is if the two identifiers merge into a single larger identifier that still "works" in the context in which it exists, effectively creating a silent error. E.g. trying to do a*b as ab when a variable ab is already defined.
Mathematica inserts a gray little multiplication icon when there's implicit multiplication
If we do the same and be consistent that every implicit multiplication has a multiplication icon, then it'll be clear when a certain syntax isn't implicit multiplication (because it lacks the implicit multiplication symbol).
Problem is the lack of space: 2x{x>3} has two implicit multiplications but no space for such a symbol.
I like the "multiplication icon" solution, though I don't see why that would break for 2x{x>3}. You'd need space to put two multiplication symbols there, but with codemirror embeds (kinda like what you do with booleans already) that should in theory be doable. I guess it could cause misalignment issues though if you ask me that's an acceptable sacrifice.
Alignment issues could be mitigated by having the multiplication symbols be in a monospace font.
Good point about the inline widgets. That was the plan anyways. Just forgot that an inline widget could be inserted that replaces nothing (if there's a space, the inline multiplication widget will replace one of the spaces).