lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> "use plenty of parentheses if you do not have enough time to work carefully with your code"

This is definitely not the advice.
Rather:
"use parentheses instead of wasting time looking up operator precedence tables"

> I understand your concern about "a/b*c".
> But why do you suggest writing "a/b/c" as "(a/b)/c" ?

Some combinations are more obvious than others.
The point is: "be aware there are some combinations with / ".
Consistently adding all / at the end is definitely less prone to errors as compared to intermixing it with *

But look at this:
               a
              ---
   a           b
-------  =  -------
   b           c
  ---
   c

... or not?

What about more than 3 numbers?
(a/b)/(c/d) vs. (a/b)/c/b vs. a/b/(c/d) vs. (a/b/c)/d vs. a/(b/c/d) vs. a/b/c/d
How many different results will you get in these 6 expressions?
Which ones are the same? How long do you need to figure this out?

Four numbers is still simple, what a combination of multiplication and division of 8 numbers?

Do not underestimate /

> An engineer can mistakenly interpret "a/b/c" as a date? :-)

I don't think so - definitely not according to my locale date format convention ;-)



On Mon, Jan 11, 2021 at 6:04 PM Egor Skriptunoff <egor.skriptunoff@gmail.com> wrote:
On Mon, Jan 11, 2021 at 4:11 PM bel wrote:
In particular if you are under pressure of time ("always").

The advice
"use plenty of parentheses if you do not have enough time to work carefully with your code"
looks not serious to me.
If you're hurrying up, the operator precedence might not be your biggest problem :-)


Anyway, the rule "after / no * or / without ()" already proved to be useful in practice.

I understand your concern about "a/b*c".
But why do you suggest writing "a/b/c" as "(a/b)/c" ?
What could go wrong here?
An engineer can mistakenly interpret "a/b/c" as a date? :-)


> A possible solution is to write LaTeX-to-Lua converter
> latex_to_lua_func

Thank you - I did not know something like this exists.
Do you have a link to this project?

Such a project probably exists.
But I implied you should write your own convertor - it's quite a simple task.