unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* In CVS Emacs, calc-eval gives multiplication higher precidence than division
@ 2008-09-07 16:06 Francis Litterio
  2008-09-07 16:37 ` Jay Belanger
  0 siblings, 1 reply; 45+ messages in thread
From: Francis Litterio @ 2008-09-07 16:06 UTC (permalink / raw)
  To: bug-gnu-emacs, emacs-devel

In CVS Emacs, function calc-eval (in lisp/calc/calc.el) gives
multiplication higher precidence than division.  To reproduce, run
"emacs -q" and evaluate this form:

   (progn
     (require 'calc)
     (calc-eval "1 / 2 * 1000"))

The value of the above form is "5e-4" (as if operator '*' has higher
precidence than operator '/'), but it should be "500".
--
Fran




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 16:06 In CVS Emacs, calc-eval gives multiplication higher precidence than division Francis Litterio
@ 2008-09-07 16:37 ` Jay Belanger
  2008-09-07 18:15   ` Francis Litterio
  2008-09-07 19:46   ` Stefan Monnier
  0 siblings, 2 replies; 45+ messages in thread
From: Jay Belanger @ 2008-09-07 16:37 UTC (permalink / raw)
  To: Francis Litterio; +Cc: jay.p.belanger, bug-gnu-emacs, emacs-devel


Francis Litterio <flitterio@gmail.com> writes:
...
> In CVS Emacs, function calc-eval (in lisp/calc/calc.el) gives
> multiplication higher precidence than division.

That's not a bug.  While many systems give division a higher precendence
than multiplication, that isn't a universal rule.  Calc has always given
multiplication a higher precendence, and something like
1 / 2 * 1000
can be viewed as shorthand for
   1
--------
2 * 1000
Some people don't like this, some people do, but this choice is
established Calc behavior and is highlighted in the manual.  To divide
first, it's probably better style regardless to put in the parentheses:
(1 / 2) * 1000

Jay




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 16:37 ` Jay Belanger
@ 2008-09-07 18:15   ` Francis Litterio
  2008-09-07 19:46   ` Stefan Monnier
  1 sibling, 0 replies; 45+ messages in thread
From: Francis Litterio @ 2008-09-07 18:15 UTC (permalink / raw)
  To: emacs-devel; +Cc: bug-gnu-emacs

Jay Belanger wrote:

> Francis Litterio writes:
> ...
>> In CVS Emacs, function calc-eval (in lisp/calc/calc.el) gives
>> multiplication higher precidence than division.
>
> That's not a bug.  While many systems give division a higher precendence
> than multiplication, that isn't a universal rule.  Calc has always given
> multiplication a higher precendence, and something like
> 1 / 2 * 1000
> can be viewed as shorthand for
>    1
> --------
> 2 * 1000
> Some people don't like this, some people do, but this choice is
> established Calc behavior and is highlighted in the manual.  To divide
> first, it's probably better style regardless to put in the parentheses:
> (1 / 2) * 1000

Thanks, Jay.

My apologies for rehashing old news.  I just discovered the discussion
thread at:

	http://thread.gmane.org/gmane.emacs.devel/69436
--
Fran





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 16:37 ` Jay Belanger
  2008-09-07 18:15   ` Francis Litterio
@ 2008-09-07 19:46   ` Stefan Monnier
  2008-09-07 20:19     ` bug#920: " Lennart Borgman (gmail)
                       ` (2 more replies)
  1 sibling, 3 replies; 45+ messages in thread
From: Stefan Monnier @ 2008-09-07 19:46 UTC (permalink / raw)
  To: jay.p.belanger; +Cc: bug-gnu-emacs, Francis Litterio, emacs-devel

> That's not a bug.  While many systems give division a higher precendence
> than multiplication, that isn't a universal rule.

Actually, I don't know of any system that gives higher precedence to
division.  The general rule that (AFAIK) all programming languages
follow (other than those that don't use infix-with-precedence, such as
Lisp and Smalltalk) is that * and / have the same precedence (and are
left associative).

I think Calc is plainly wrong is giving higher precedence to the
multiplication because it's completely non standard.  But since I don't
use Calc much and since it's been that way for a while, I won't fight
for it.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#920: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 19:46   ` Stefan Monnier
@ 2008-09-07 20:19     ` Lennart Borgman (gmail)
  2008-09-07 20:32     ` Randal L. Schwartz
  2008-09-07 20:35     ` Jay Belanger
  2 siblings, 0 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-07 20:19 UTC (permalink / raw)
  To: Stefan Monnier, 920
  Cc: jay.p.belanger, bug-gnu-emacs, Francis Litterio, emacs-devel

Stefan Monnier wrote:
> I think Calc is plainly wrong is giving higher precedence to the
> multiplication because it's completely non standard.  But since I don't
> use Calc much and since it's been that way for a while, I won't fight
> for it.


I think there are good reasons fixing it:

- There are enough people out there that are not aware of the precedence
rules. Making calc follow them would help remove that confusion. (And I
would feel safer when crossing bridges.)
- Not following standards makes Emacs harder to use for new users.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 19:46   ` Stefan Monnier
  2008-09-07 20:19     ` bug#920: " Lennart Borgman (gmail)
@ 2008-09-07 20:32     ` Randal L. Schwartz
  2008-09-07 20:34       ` Lennart Borgman (gmail)
  2008-09-08 10:30       ` Carsten Dominik
  2008-09-07 20:35     ` Jay Belanger
  2 siblings, 2 replies; 45+ messages in thread
From: Randal L. Schwartz @ 2008-09-07 20:32 UTC (permalink / raw)
  To: emacs-devel; +Cc: bug-gnu-emacs

>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:

Stefan> I think Calc is plainly wrong is giving higher precedence to the
Stefan> multiplication because it's completely non standard.  But since I don't
Stefan> use Calc much and since it's been that way for a while, I won't fight
Stefan> for it.

Given the original author's mathematics bias, it made sense (to me, as
an early tester and contributor) that:

   2 * 3 / 4 * 5

would be parsed as

   (2 * 3) / (4 * 5)

in a mathematical sense.

Admittedly, if you're a computer-science guy and not a math guy, this might
seem initially odd.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 20:32     ` Randal L. Schwartz
@ 2008-09-07 20:34       ` Lennart Borgman (gmail)
  2008-09-07 20:38         ` Randal L. Schwartz
  2008-09-08 10:30       ` Carsten Dominik
  1 sibling, 1 reply; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-07 20:34 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: emacs-devel

Randal L. Schwartz wrote:
>>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 
> Stefan> I think Calc is plainly wrong is giving higher precedence to the
> Stefan> multiplication because it's completely non standard.  But since I don't
> Stefan> use Calc much and since it's been that way for a while, I won't fight
> Stefan> for it.
> 
> Given the original author's mathematics bias, it made sense (to me, as
> an early tester and contributor) that:
> 
>    2 * 3 / 4 * 5
> 
> would be parsed as
> 
>    (2 * 3) / (4 * 5)
> 
> in a mathematical sense.
> 
> Admittedly, if you're a computer-science guy and not a math guy, this might
> seem initially odd.

It is really odd if you happen to know math.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 19:46   ` Stefan Monnier
  2008-09-07 20:19     ` bug#920: " Lennart Borgman (gmail)
  2008-09-07 20:32     ` Randal L. Schwartz
@ 2008-09-07 20:35     ` Jay Belanger
  2008-09-07 21:15       ` Stefan Monnier
  2 siblings, 1 reply; 45+ messages in thread
From: Jay Belanger @ 2008-09-07 20:35 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: jay.p.belanger, bug-gnu-emacs, Francis Litterio, emacs-devel


>> That's not a bug.  While many systems give division a higher precendence
>> than multiplication, that isn't a universal rule.
>
> Actually, I don't know of any system that gives higher precedence to
> division.

According to Wikipedia:
  An expression like 1/2x is interpreted as 1/(2x) by TI-82, but as
  (1/2)x by TI-83. While the first interpretation may be expected by
  some users, only the latter is in agreement with the standard rules
  stated above. 

> The general rule that (AFAIK) all programming languages
> follow (other than those that don't use infix-with-precedence, such as
> Lisp and Smalltalk) is that * and / have the same precedence (and are
> left associative).

That behavior is available, but you have to ask for it by setting
`calc-multiplication-has-precedence' to nil.





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-07 20:34       ` Lennart Borgman (gmail)
@ 2008-09-07 20:38         ` Randal L. Schwartz
  2008-09-07 20:42           ` Lennart Borgman (gmail)
  2008-09-07 21:10           ` Stefan Monnier
  0 siblings, 2 replies; 45+ messages in thread
From: Randal L. Schwartz @ 2008-09-07 20:38 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel

>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:

>> Admittedly, if you're a computer-science guy and not a math guy, this might
>> seem initially odd.

Lennart> It is really odd if you happen to know math.

Really?

You parse

    a b / c d

as ((a * b) / c) * d ?

That's not what I was taught in algebra.  Have the rules changed?

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-07 20:38         ` Randal L. Schwartz
@ 2008-09-07 20:42           ` Lennart Borgman (gmail)
  2008-09-07 20:50             ` Randal L. Schwartz
  2008-09-08  1:13             ` Randal L. Schwartz
  2008-09-07 21:10           ` Stefan Monnier
  1 sibling, 2 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-07 20:42 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: emacs-devel

Randal L. Schwartz wrote:
>>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:
> 
>>> Admittedly, if you're a computer-science guy and not a math guy, this might
>>> seem initially odd.
> 
> Lennart> It is really odd if you happen to know math.
> 
> Really?
> 
> You parse
> 
>     a b / c d
> 
> as ((a * b) / c) * d ?
> 
> That's not what I was taught in algebra.  Have the rules changed?

No, I do not think they have. But maybe your teacher is on another job
now ... ;-)

More seriously: Where do you get those rules from? The notation

  a b / c d

does not look like a standard math notation.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence   than division
  2008-09-07 20:42           ` Lennart Borgman (gmail)
@ 2008-09-07 20:50             ` Randal L. Schwartz
  2008-09-07 21:07               ` Lennart Borgman (gmail)
                                 ` (2 more replies)
  2008-09-08  1:13             ` Randal L. Schwartz
  1 sibling, 3 replies; 45+ messages in thread
From: Randal L. Schwartz @ 2008-09-07 20:50 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel

>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:

Lennart> More seriously: Where do you get those rules from? The notation

Lennart>   a b / c d

Lennart> does not look like a standard math notation.

You sound serious, or perhaps you've only seen math in the computer era.  What
do you get when you run:

a b \div c d

through LaTeX?  I can't type it in ASCII, but that's what I'm talking about.
And in ASCII, we wrote it like "a b / c d".

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence than division
  2008-09-07 20:50             ` Randal L. Schwartz
@ 2008-09-07 21:07               ` Lennart Borgman (gmail)
  2008-09-08  6:39                 ` Ulrich Mueller
  2008-09-07 21:10               ` Stefan Monnier
  2008-09-08  0:50               ` Jason Rumney
  2 siblings, 1 reply; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-07 21:07 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: emacs-devel

Randal L. Schwartz wrote:
>>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:
> 
> Lennart> More seriously: Where do you get those rules from? The notation
> 
> Lennart>   a b / c d
> 
> Lennart> does not look like a standard math notation.
> 
> You sound serious, or perhaps you've only seen math in the computer era.

No, I got my knowledge in that area from math. Of course there may be
different notation used in different math books, but for basic math
calculations with numbers I think you should use the standard notation
for just that.

If some algebra books use "simplified notation" the best thing to do
might be to burn them. There is no need to complicate things with
unneeded extra notations that makes it hard to read the books. Algebra
is not so much about that. (But of course, sadly enough I have seen
books using their own subfield notation.)

> What
> do you get when you run:
> 
> a b \div c d
> 
> through LaTeX?

I never use LaTeX so I do not know. But why do you refer to LaTeX here?

> I can't type it in ASCII, but that's what I'm talking about.
> And in ASCII, we wrote it like "a b / c d".






^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence   than division
  2008-09-07 20:50             ` Randal L. Schwartz
  2008-09-07 21:07               ` Lennart Borgman (gmail)
@ 2008-09-07 21:10               ` Stefan Monnier
  2008-09-07 23:30                 ` Jay Belanger
  2008-09-08  0:50               ` Jason Rumney
  2 siblings, 1 reply; 45+ messages in thread
From: Stefan Monnier @ 2008-09-07 21:10 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Lennart Borgman (gmail), emacs-devel

> You sound serious, or perhaps you've only seen math in the computer
> era.  What do you get when you run:

> a b \div c d

> through LaTeX?

LaTeX doesn't have much notion of precedence anyway, so all it does is
reflect the layout you intended.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-07 20:38         ` Randal L. Schwartz
  2008-09-07 20:42           ` Lennart Borgman (gmail)
@ 2008-09-07 21:10           ` Stefan Monnier
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Monnier @ 2008-09-07 21:10 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Lennart Borgman (gmail), emacs-devel

> You parse
>     a b / c d
> as ((a * b) / c) * d ?

"a b / c d" is completely different from "a * b / c * d"
w.r.t. precedence.  And so is "a * b ÷ c * d" or "a × b ÷ c × d".
There's no good reason why they necessarily all three get
parsed identically.

As it so happens, Calc is the only tool I know which parses
"a * b / c * d" differently than "((a * b) / c) * d".  So whether it
makes sense or not doesn't really matter, because the other way to parse
it also makes sense and has the benefit of agreeing with the world
out there.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 20:35     ` Jay Belanger
@ 2008-09-07 21:15       ` Stefan Monnier
  2008-09-07 21:19         ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 45+ messages in thread
From: Stefan Monnier @ 2008-09-07 21:15 UTC (permalink / raw)
  To: jay.p.belanger; +Cc: bug-gnu-emacs, Francis Litterio, emacs-devel

>>> That's not a bug.  While many systems give division a higher precendence
>>> than multiplication, that isn't a universal rule.
>> Actually, I don't know of any system that gives higher precedence to
>> division.

> According to Wikipedia:
>   An expression like 1/2x is interpreted as 1/(2x) by TI-82, but as
>   (1/2)x by TI-83. While the first interpretation may be expected by
>   some users, only the latter is in agreement with the standard rules
>   stated above. 

That could be due to a higher precedence, but could also be due to an
equal precedence together with left-associativity.  Given that (a*b)/c
is often mathematically equal to a*(b/c), the difference is generally
hard to see, unless rounding comes into play.

All textbooks and language references I know use the "equal precedence
and left associativity" rule rather than giving higher precedence to
the division.

>> The general rule that (AFAIK) all programming languages
>> follow (other than those that don't use infix-with-precedence, such as
>> Lisp and Smalltalk) is that * and / have the same precedence (and are
>> left associative).

> That behavior is available, but you have to ask for it by setting
> `calc-multiplication-has-precedence' to nil.

I know.  But we're talking about the default behavior.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 21:15       ` Stefan Monnier
@ 2008-09-07 21:19         ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-07 21:19 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: jay.p.belanger, bug-gnu-emacs, Francis Litterio, emacs-devel

Stefan Monnier wrote:
>> According to Wikipedia:
>>   An expression like 1/2x is interpreted as 1/(2x) by TI-82, but as
>>   (1/2)x by TI-83. While the first interpretation may be expected by
>>   some users, only the latter is in agreement with the standard rules
>>   stated above. 
> 
> That could be due to a higher precedence, but could also be due to an
> equal precedence together with left-associativity.  Given that (a*b)/c
> is often mathematically equal to a*(b/c), the difference is generally
> hard to see, unless rounding comes into play.

But that is a bit different from (a/b)*c, a/(b*c) ... - otherwise I agree.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence   than division
  2008-09-07 21:10               ` Stefan Monnier
@ 2008-09-07 23:30                 ` Jay Belanger
  0 siblings, 0 replies; 45+ messages in thread
From: Jay Belanger @ 2008-09-07 23:30 UTC (permalink / raw)
  To: Stefan Monnier
  Cc: jay.p.belanger, emacs-devel, Lennart Borgman (gmail),
	Randal L. Schwartz


Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> You sound serious, or perhaps you've only seen math in the computer
>> era.  What do you get when you run:
>
>> a b \div c d
>
>> through LaTeX?
>
> LaTeX doesn't have much notion of precedence anyway, so all it does is
> reflect the layout you intended.

In this case, TeX has a notion of precedence (not that I think it
matters).  $$a b \over c d$$ gets typeset as
a b
---
c d

Jay




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence than division
  2008-09-07 20:50             ` Randal L. Schwartz
  2008-09-07 21:07               ` Lennart Borgman (gmail)
  2008-09-07 21:10               ` Stefan Monnier
@ 2008-09-08  0:50               ` Jason Rumney
  2 siblings, 0 replies; 45+ messages in thread
From: Jason Rumney @ 2008-09-08  0:50 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Lennart Borgman (gmail), emacs-devel

Randal L. Schwartz wrote:

> You sound serious, or perhaps you've only seen math in the computer era.  What
> do you get when you run:
>
> a b \div c d
>
> through LaTeX?

You get a visual representation of a different equation than a * b / c * d






^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-07 20:42           ` Lennart Borgman (gmail)
  2008-09-07 20:50             ` Randal L. Schwartz
@ 2008-09-08  1:13             ` Randal L. Schwartz
  2008-09-08  3:47               ` Stefan Monnier
  2008-09-08  7:26               ` Lennart Borgman (gmail)
  1 sibling, 2 replies; 45+ messages in thread
From: Randal L. Schwartz @ 2008-09-08  1:13 UTC (permalink / raw)
  To: emacs-devel

>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:

Lennart> More seriously: Where do you get those rules from? The notation

Lennart>   a b / c d

Lennart> does not look like a standard math notation.

If a is 2, and c is 5, you're actually telling me that *you*
would parse:

      2 b / 5 d

as ((2 * b) / 5) * d ?

That's crazy.

That's (2b)/(5d), according to any math teacher I knew from school.

That's the only sane parsing of that.

Now, replace 2 with "a" and 5 with "c", and you get:

  ab/cd

which is (ab)/(cd).

That's what I mean. This is the *mathematical* evaluation.  In this case,
division *is* lower precedence than multiplication.

Anyway, maybe you've never seen expressions like 2a/5d before.  I dealt with
them in my algebra class, but perhaps that was before you were born, and
before computers came into usage in high schools.  I suppose the rules changed
once we started teaching * and / as same precedence in computer science, which
then leaked over into math notation as well.

I'm probably not going to convince you of anything here, but I did want to
come up with a better example, now that I'm going through the calc manual
again.  And then, it made perfect sense, as it still does.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-08  1:13             ` Randal L. Schwartz
@ 2008-09-08  3:47               ` Stefan Monnier
  2008-09-08  8:48                 ` Miles Bader
  2008-09-08  7:26               ` Lennart Borgman (gmail)
  1 sibling, 1 reply; 45+ messages in thread
From: Stefan Monnier @ 2008-09-08  3:47 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: emacs-devel

> If a is 2, and c is 5, you're actually telling me that *you*
> would parse:

>       2 b / 5 d

> as ((2 * b) / 5) * d ?

> That's crazy.

> That's (2b)/(5d), according to any math teacher I knew from school.

> That's the only sane parsing of that.

> Now, replace 2 with "a" and 5 with "c", and you get:

>   ab/cd

> which is (ab)/(cd).

Again "a b" is not the same as "a * b", and "ab" is even a lot
more different (given the lack of even a space, it's hard to argue that
there could be something that binds more tightly).
So this argument is irrelevant.  I.e. I agree if Calc gives higher
precedence to the implicit multiplication operator, but not if it does
so to the "*" multiplication operator.



        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence than division
  2008-09-07 21:07               ` Lennart Borgman (gmail)
@ 2008-09-08  6:39                 ` Ulrich Mueller
  2008-09-08  7:07                   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 45+ messages in thread
From: Ulrich Mueller @ 2008-09-08  6:39 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-devel, Randal L. Schwartz

>>>>> On Sun, 07 Sep 2008, Lennart Borgman (gmail) wrote:

> If some algebra books use "simplified notation" the best thing to do
> might be to burn them.

Lennart,

could you please leave such polemic out of the discussion? I find the
suggestion to burn books to be in very bad taste.

Also, the topic has been discussed in ample length before:
http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00557.html

Ulrich

-- 
"Das war ein Vorspiel nur, dort wo man Bücher verbrennt,
verbrennt man auch am Ende Menschen." - Heinrich Heine (1821)




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher   precidence than division
  2008-09-08  6:39                 ` Ulrich Mueller
@ 2008-09-08  7:07                   ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-08  7:07 UTC (permalink / raw)
  To: Ulrich Mueller; +Cc: emacs-devel, Randal L. Schwartz

Ulrich Mueller wrote:
>>>>>> On Sun, 07 Sep 2008, Lennart Borgman (gmail) wrote:
> 
>> If some algebra books use "simplified notation" the best thing to do
>> might be to burn them.
> 
> Lennart,
> 
> could you please leave such polemic out of the discussion? I find the
> suggestion to burn books to be in very bad taste.

Ok, sorry, but this is not about politics or similar things where I
would never write such things.

I am just very tired of different notations that just makes it harder
for some people to learn.

It is a bit frightened that pupils on the introductory courses at
university level do not know these precedence rules. (Though I would not
mind if they were not reading math.)

> Also, the topic has been discussed in ample length before:
> http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00557.html

Thanks. I found these two worth reading:

http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00654.html
http://lists.gnu.org/archive/html/emacs-devel/2007-04/msg00905.html




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-08  1:13             ` Randal L. Schwartz
  2008-09-08  3:47               ` Stefan Monnier
@ 2008-09-08  7:26               ` Lennart Borgman (gmail)
  1 sibling, 0 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-08  7:26 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: emacs-devel

Randal L. Schwartz wrote:
> That's crazy.
> 
> That's (2b)/(5d), according to any math teacher I knew from school.
> 
> That's the only sane parsing of that.
> 
> Now, replace 2 with "a" and 5 with "c", and you get:
> 
>   ab/cd
> 
> which is (ab)/(cd).
> 
> That's what I mean. This is the *mathematical* evaluation.  In this case,
> division *is* lower precedence than multiplication.

I am afraid I think you misunderstand this issue. We are talking about

  a * b / c * d

But thanks, maybe I can understand a bit better why some people believe
that these precedence rules exists now. Indeed, as you pointed out "2b"
is often interpreted as "2 * b" and that might give the impression that
there is a precedence rule for * and / that says * has higher precedence.

But there is no such rule. It is about different notations instead.

You have to be more careful when translating notations. The notation
translation is rather

  2b / 5d => (2 * b) / (5 * d)




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-08  3:47               ` Stefan Monnier
@ 2008-09-08  8:48                 ` Miles Bader
  2008-09-08 12:59                   ` Stefan Monnier
  2008-09-08 13:29                   ` martin rudalics
  0 siblings, 2 replies; 45+ messages in thread
From: Miles Bader @ 2008-09-08  8:48 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel, Randal L. Schwartz

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Again "a b" is not the same as "a * b", and "ab" is even a lot
> more different (given the lack of even a space, it's hard to argue that
> there could be something that binds more tightly).
> So this argument is irrelevant.  I.e. I agree if Calc gives higher
> precedence to the implicit multiplication operator, but not if it does
> so to the "*" multiplication operator.

Hm but in calc there doesn't seem to be any differentiation between
"implicit" and "explicit" multiplication...  You can enter "a b / c d"
and it is displayed the same (without the *, by default) as if you enter
"a*b / c*d".  I guess it just treats them as different names for the
same thing...

-Miles

-- 
Twice, adv. Once too often.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-07 20:32     ` Randal L. Schwartz
  2008-09-07 20:34       ` Lennart Borgman (gmail)
@ 2008-09-08 10:30       ` Carsten Dominik
  2008-09-08 11:01         ` Lennart Borgman
  2008-09-08 13:01         ` Stefan Monnier
  1 sibling, 2 replies; 45+ messages in thread
From: Carsten Dominik @ 2008-09-08 10:30 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: bug-gnu-emacs, emacs-devel


On Sep 7, 2008, at 10:32 PM, Randal L. Schwartz wrote:

>>>>>> "Stefan" == Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> Stefan> I think Calc is plainly wrong is giving higher precedence to  
> the
> Stefan> multiplication because it's completely non standard.  But  
> since I don't
> Stefan> use Calc much and since it's been that way for a while, I  
> won't fight
> Stefan> for it.


I would fight for the current calc implementation, it is an important  
convenience when entering equations.  I am relying on it every day.

- Carsten



>
>
> Given the original author's mathematics bias, it made sense (to me, as
> an early tester and contributor) that:
>
>   2 * 3 / 4 * 5
>
> would be parsed as
>
>   (2 * 3) / (4 * 5)
>
> in a mathematical sense.
>
> Admittedly, if you're a computer-science guy and not a math guy,  
> this might
> seem initially odd.
>
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503  
> 777 0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
> See http://methodsandmessages.vox.com/ for Smalltalk and Seaside  
> discussion
>
>
>





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-08 10:30       ` Carsten Dominik
@ 2008-09-08 11:01         ` Lennart Borgman
  2008-09-08 20:33           ` Carsten Dominik
  2008-09-08 13:01         ` Stefan Monnier
  1 sibling, 1 reply; 45+ messages in thread
From: Lennart Borgman @ 2008-09-08 11:01 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: bug-gnu-emacs, emacs-devel, Randal L. Schwartz

On 9/8/08, Carsten Dominik <carsten.dominik@gmail.com> > I would fight
for the current calc implementation, it is an important
> convenience when entering equations.  I am relying on it every day.

Exactly how are you relying on that the current behaviour is the default?




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-08  8:48                 ` Miles Bader
@ 2008-09-08 12:59                   ` Stefan Monnier
  2008-09-08 13:29                   ` martin rudalics
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Monnier @ 2008-09-08 12:59 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel, Randal L. Schwartz

>> Again "a b" is not the same as "a * b", and "ab" is even a lot
>> more different (given the lack of even a space, it's hard to argue that
>> there could be something that binds more tightly).
>> So this argument is irrelevant.  I.e. I agree if Calc gives higher
>> precedence to the implicit multiplication operator, but not if it does
>> so to the "*" multiplication operator.

> Hm but in calc there doesn't seem to be any differentiation between
> "implicit" and "explicit" multiplication...  You can enter "a b / c d"
> and it is displayed the same (without the *, by default) as if you enter
> "a*b / c*d".  I guess it just treats them as different names for the
> same thing...

That both operators are accepted and get represented internally as the
same ASA node doesn't mean they have to have the same precedence.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-08 10:30       ` Carsten Dominik
  2008-09-08 11:01         ` Lennart Borgman
@ 2008-09-08 13:01         ` Stefan Monnier
  1 sibling, 0 replies; 45+ messages in thread
From: Stefan Monnier @ 2008-09-08 13:01 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: bug-gnu-emacs, emacs-devel, Randal L. Schwartz

> I would fight for the current calc implementation, it is an important
> convenience when entering equations.  I am relying on it every day.

It's really a very minor issue that only determines when and where you
need to place parentheses.  And you can control it with a config var in
case you don't like the default.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-08  8:48                 ` Miles Bader
  2008-09-08 12:59                   ` Stefan Monnier
@ 2008-09-08 13:29                   ` martin rudalics
  1 sibling, 0 replies; 45+ messages in thread
From: martin rudalics @ 2008-09-08 13:29 UTC (permalink / raw)
  To: Miles Bader; +Cc: emacs-devel

 > Hm but in calc there doesn't seem to be any differentiation between
 > "implicit" and "explicit" multiplication...  You can enter "a b / c d"
 > and it is displayed the same (without the *, by default) as if you enter
 > "a*b / c*d".  I guess it just treats them as different names for the
 > same thing...

Ideally, after entering something like "a b /" calc could use overlays
(with some subdued face) to display parentheses and the multiplication
operator at the positions anticipated by calc.

martin





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-08 11:01         ` Lennart Borgman
@ 2008-09-08 20:33           ` Carsten Dominik
  2008-09-08 20:39             ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 45+ messages in thread
From: Carsten Dominik @ 2008-09-08 20:33 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: bug-gnu-emacs, emacs-devel, Randal L. Schwartz


On Sep 8, 2008, at 1:01 PM, Lennart Borgman wrote:

> On 9/8/08, Carsten Dominik <carsten.dominik@gmail.com> > I would fight
> for the current calc implementation, it is an important
>> convenience when entering equations.  I am relying on it every day.
>
> Exactly how are you relying on that the current behaviour is the  
> default?


By typing algebraic equations into the minibuffer and saving tons of  
key strokes by leaving off parenthesis.  I often type equations like

  p = n k T / mu mp

and it saves me 4 key strokes to not having to type the parenthesis

  p = (n k T) / (mu mp)

- Carsten






^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher precidence than division
  2008-09-08 20:33           ` Carsten Dominik
@ 2008-09-08 20:39             ` Lennart Borgman (gmail)
  2008-09-08 20:43               ` Randal L. Schwartz
  0 siblings, 1 reply; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-08 20:39 UTC (permalink / raw)
  To: Carsten Dominik; +Cc: bug-gnu-emacs, emacs-devel, Randal L. Schwartz

Carsten Dominik wrote:
> 
> On Sep 8, 2008, at 1:01 PM, Lennart Borgman wrote:
> 
>> On 9/8/08, Carsten Dominik <carsten.dominik@gmail.com> > I would fight
>> for the current calc implementation, it is an important
>>> convenience when entering equations.  I am relying on it every day.
>>
>> Exactly how are you relying on that the current behaviour is the default?
> 
> 
> By typing algebraic equations into the minibuffer and saving tons of key
> strokes by leaving off parenthesis.  I often type equations like
> 
>  p = n k T / mu mp
> 
> and it saves me 4 key strokes to not having to type the parenthesis
> 
>  p = (n k T) / (mu mp)


Yes, sorry, I should not have asked like that. I get a little bit upset
that many people here accept defaults that can make it harder for
newbees just for a little bit convenience. (But I guess I am a bit
unfair. Someone more in favour of the view opposite to mine in this
question can surely put it more nicely.)

Of course I can see that the behaviour you want saves you a lot of key
strokes. My question is really about the default value. You can easily
change that, of course. The question is really if you prefer the old
default and in that case what arguments you want to present for that.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-08 20:39             ` Lennart Borgman (gmail)
@ 2008-09-08 20:43               ` Randal L. Schwartz
  2008-09-08 20:53                 ` Lennart Borgman (gmail)
                                   ` (2 more replies)
  0 siblings, 3 replies; 45+ messages in thread
From: Randal L. Schwartz @ 2008-09-08 20:43 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: bug-gnu-emacs, emacs-devel, Carsten Dominik

>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:

Lennart> Of course I can see that the behaviour you want saves you a lot of key
Lennart> strokes. My question is really about the default value. You can easily
Lennart> change that, of course. The question is really if you prefer the old
Lennart> default and in that case what arguments you want to present for that.

There's no need to change the longstanding defaults, because it would break
things.  You already have a knob you can tweak if you think that "2 a / 3 b"
should multiply by b, rather than divide by it.  That's a personal choice.

Frankly, I'd never touch that knob, because it looks to me like it should
divide by b.  And I think most mathemeticians would agree, and that's the
target for that part of Calc.  Stop thinking computer science.  Think
*math* notation.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-08 20:43               ` Randal L. Schwartz
@ 2008-09-08 20:53                 ` Lennart Borgman (gmail)
  2008-09-08 22:59                   ` bug#914: " Jay Belanger
  2008-09-08 21:42                 ` Stefan Monnier
  2008-09-09  8:11                 ` Richard M. Stallman
  2 siblings, 1 reply; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-08 20:53 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: emacs-devel, 914, Carsten Dominik

Randal L. Schwartz wrote:
>>>>>> "Lennart" == Lennart Borgman (gmail) <lennart.borgman@gmail.com> writes:
> 
> Lennart> Of course I can see that the behaviour you want saves you a lot of key
> Lennart> strokes. My question is really about the default value. You can easily
> Lennart> change that, of course. The question is really if you prefer the old
> Lennart> default and in that case what arguments you want to present for that.
> 
> There's no need to change the longstanding defaults, because it would break
> things.  You already have a knob you can tweak if you think that "2 a / 3 b"
> should multiply by b, rather than divide by it.  That's a personal choice.

I think communication can be very difficult if you have too much
personal choice in it. Math is about communication (for a special class
of logical problems).

The original bug report was about this

  (calc-eval "1 / 2 * 1000")

Calc treats this as 1 / (2 * 1000) which is just plain wrong. I have
never seen a mathematician treat it that way - though I have seen many
pupils doing that.


> Frankly, I'd never touch that knob, because it looks to me like it should
> divide by b.  And I think most mathemeticians would agree, and that's the
> target for that part of Calc.  Stop thinking computer science.  Think
> *math* notation.





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-08 20:43               ` Randal L. Schwartz
  2008-09-08 20:53                 ` Lennart Borgman (gmail)
@ 2008-09-08 21:42                 ` Stefan Monnier
  2008-09-09  8:11                 ` Richard M. Stallman
  2 siblings, 0 replies; 45+ messages in thread
From: Stefan Monnier @ 2008-09-08 21:42 UTC (permalink / raw)
  To: Randal L. Schwartz
  Cc: bug-gnu-emacs, Carsten Dominik, Lennart Borgman (gmail),
	emacs-devel

Lennart> Of course I can see that the behaviour you want saves you a lot of key
Lennart> strokes. My question is really about the default value. You can easily
Lennart> change that, of course. The question is really if you prefer the old
Lennart> default and in that case what arguments you want to present for that.

> There's no need to change the longstanding defaults, because it would break
> things.  You already have a knob you can tweak if you think that "2 a / 3 b"
> should multiply by b, rather than divide by it.  That's a personal choice.

Nobody in this thread has said that "2 a / 3 b" should multiply by b.
What I (and others) have said is that "2 * a / 3 * b" should multiply by b.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-08 20:53                 ` Lennart Borgman (gmail)
@ 2008-09-08 22:59                   ` Jay Belanger
  2008-09-08 23:44                     ` Lennart Borgman (gmail)
  2008-09-09 13:28                     ` Stefan Monnier
  0 siblings, 2 replies; 45+ messages in thread
From: Jay Belanger @ 2008-09-08 22:59 UTC (permalink / raw)
  To: Lennart Borgman (gmail)
  Cc: jay.p.belanger, emacs-devel, Carsten Dominik, Randal L. Schwartz


First of all, we really need to make sure that any follow ups to any
branches of this thread are not sent to emacs bugs.

"Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
...
> The original bug report was about this
>
>   (calc-eval "1 / 2 * 1000")
>
> Calc treats this as 1 / (2 * 1000) which is just plain wrong.

That's overstating it.

> I have never seen a mathematician treat it that way - though I have
> seen many pupils doing that.

While there may be counterexamples, I have never seen a mathematician
write 1 / 2 * 1000 when he means (1 / 2) * 1000.  Leaving off the
paretheses may be parsable in many languages, but it's poor style in
mathematics.
The Calc shortcut under discussion has been around for 20 years and
there have already been lengthy discussions about it.  I don't know why
it's being rehashed again. 






^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher precidence  than division
  2008-09-08 22:59                   ` bug#914: " Jay Belanger
@ 2008-09-08 23:44                     ` Lennart Borgman (gmail)
  2008-09-09 13:28                     ` Stefan Monnier
  1 sibling, 0 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-08 23:44 UTC (permalink / raw)
  To: jay.p.belanger; +Cc: emacs-devel, Carsten Dominik, Randal L. Schwartz

Jay Belanger wrote:
>> The original bug report was about this
>>
>>   (calc-eval "1 / 2 * 1000")
>>
>> Calc treats this as 1 / (2 * 1000) which is just plain wrong.
> 
> That's overstating it.

Not if you use the usual precedence rules in math. Then it is plain
wrong. No less and no more.

If you want to use some other logic then of course it is not wrong.

>> I have never seen a mathematician treat it that way - though I have
>> seen many pupils doing that.
> 
> While there may be counterexamples, I have never seen a mathematician
> write 1 / 2 * 1000 when he means (1 / 2) * 1000.

Strange. I think it is common that you know and use the precedence rules.

Of course I agree with you that it is good practice to use parenthesis,
but that is another thing.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-08 20:43               ` Randal L. Schwartz
  2008-09-08 20:53                 ` Lennart Borgman (gmail)
  2008-09-08 21:42                 ` Stefan Monnier
@ 2008-09-09  8:11                 ` Richard M. Stallman
  2008-09-09 13:26                   ` Stefan Monnier
  2 siblings, 1 reply; 45+ messages in thread
From: Richard M. Stallman @ 2008-09-09  8:11 UTC (permalink / raw)
  To: Randal L. Schwartz
  Cc: bug-gnu-emacs, carsten.dominik, lennart.borgman, emacs-devel

    There's no need to change the longstanding defaults, because it would break
    things.  You already have a knob you can tweak if you think that "2 a / 3 b"
    should multiply by b, rather than divide by it.  That's a personal choice.

    Frankly, I'd never touch that knob, because it looks to me like it should
    divide by b.

I agree completely -- in that case, it is natural for b to go in the
denominator.

The same is true for 1 / 2 * 1000: the meaning of 1/2000 is more
natural, mathematically.

What Calc does now is clearly correct.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-09  8:11                 ` Richard M. Stallman
@ 2008-09-09 13:26                   ` Stefan Monnier
  2008-09-09 17:03                     ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 45+ messages in thread
From: Stefan Monnier @ 2008-09-09 13:26 UTC (permalink / raw)
  To: rms
  Cc: bug-gnu-emacs, carsten.dominik, lennart.borgman, emacs-devel,
	Randal L. Schwartz

> What Calc does now is clearly correct.

And we clearly disagree.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-08 22:59                   ` bug#914: " Jay Belanger
  2008-09-08 23:44                     ` Lennart Borgman (gmail)
@ 2008-09-09 13:28                     ` Stefan Monnier
  2008-09-09 14:36                       ` Francis Litterio
  1 sibling, 1 reply; 45+ messages in thread
From: Stefan Monnier @ 2008-09-09 13:28 UTC (permalink / raw)
  To: jay.p.belanger
  Cc: Randal L. Schwartz, Carsten Dominik, Lennart Borgman (gmail),
	emacs-devel

> I don't know why it's being rehashed again. 

Because someone reported it as a bug, not realizing that this
non-standard behavior is considered as a feature.


        Stefan





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-09 13:28                     ` Stefan Monnier
@ 2008-09-09 14:36                       ` Francis Litterio
  2008-09-09 16:26                         ` Ulrich Mueller
  2008-09-30  4:10                         ` Leo
  0 siblings, 2 replies; 45+ messages in thread
From: Francis Litterio @ 2008-09-09 14:36 UTC (permalink / raw)
  To: emacs-devel

Stefan Monnier wrote:

>> I don't know why it's being rehashed again. 
>
> Because someone reported it as a bug, not realizing that this
> non-standard behavior is considered as a feature.

That would be me.  Sorry.

But we should be prepared for more bug reports about this, unless some
means can be devised to alert Calc users about the precedence rule.

Would it be in appropriate to append a comment to the result when Calc
is used interactively?
--
Fran





^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-09 14:36                       ` Francis Litterio
@ 2008-09-09 16:26                         ` Ulrich Mueller
  2008-09-09 16:41                           ` Lennart Borgman (gmail)
  2008-09-30  4:10                         ` Leo
  1 sibling, 1 reply; 45+ messages in thread
From: Ulrich Mueller @ 2008-09-09 16:26 UTC (permalink / raw)
  To: Francis Litterio; +Cc: emacs-devel

>>>>> On Tue, 09 Sep 2008, Francis Litterio wrote:

> But we should be prepared for more bug reports about this, unless some
> means can be devised to alert Calc users about the precedence rule.

> Would it be in appropriate to append a comment to the result when Calc
> is used interactively?

I thought the problem (if there is one) existed only when evaluating
algebraic notation? If used interactively, calc is using RPN and there
is no ambiguity:

   1 RET 2 / 1000 *      is   (1 / 2) * 1000
   1 RET 2 RET 1000 * /  is   1 / (2 * 1000)

Am I mising something?

Ulrich




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher precidence  than division
  2008-09-09 16:26                         ` Ulrich Mueller
@ 2008-09-09 16:41                           ` Lennart Borgman (gmail)
  0 siblings, 0 replies; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-09 16:41 UTC (permalink / raw)
  To: Ulrich Mueller; +Cc: Francis Litterio, emacs-devel

Ulrich Mueller wrote:
>>>>>> On Tue, 09 Sep 2008, Francis Litterio wrote:
> 
>> But we should be prepared for more bug reports about this, unless some
>> means can be devised to alert Calc users about the precedence rule.
> 
>> Would it be in appropriate to append a comment to the result when Calc
>> is used interactively?
> 
> I thought the problem (if there is one) existed only when evaluating
> algebraic notation? If used interactively, calc is using RPN and there
> is no ambiguity:
> 
>    1 RET 2 / 1000 *      is   (1 / 2) * 1000
>    1 RET 2 RET 1000 * /  is   1 / (2 * 1000)
> 
> Am I mising something?


Yes, there is an "algebraic mode". This is described in

  (info "(Calc) Algebraic Tutorial")

On top of this is a big remark which tells about the non-standard
precedence rule we have been discussing:

   *Warning:* Note that `/' has lower precedence than `*', so that
   `a/b*c' is interpreted as `a/(b*c)'.  See below for details.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-09 13:26                   ` Stefan Monnier
@ 2008-09-09 17:03                     ` Lennart Borgman (gmail)
  2008-09-09 17:19                       ` Stefan Monnier
  0 siblings, 1 reply; 45+ messages in thread
From: Lennart Borgman (gmail) @ 2008-09-09 17:03 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Carsten Dominik, emacs-devel, rms, Randal L. Schwartz

Stefan Monnier wrote:
>> What Calc does now is clearly correct.
> 
> And we clearly disagree.


On way of getting out of this trouble would perhaps be to distinguish
between an explicit and an implicit `*'. In the explicit case the normal
precedence rules should be used, but in the implicit case the current
precedence rules might be used instead. The basis for this would be that
way allude on the common formula notation.

Doing this then

  8 / 2 * 2 = (8 / 2) * 2 = 8

and

  8 / 2 2 => 8 / (2 * 2) = 2

The first example above follow normal math syntax and semantics. The
second example is rather close to what is often used in formulas, like

  ax/by + cz => (a * x) / (b * y) + c * z

Normally this kind of syntax is of course used in a well defined context
where you want a short notation for formulas. But it looks like Calc has
been striving towards the second in an attempt to make it easier to
enter data. I don't think that this is a bad idea.

The goal to make it easier to enter data have been reach, but
unfortunately a by product has been that Calc mixes the two common cases
of syntax/semantics that are most widely used as far as I know.

However in my opinion distinguishing the cases like above might be a
good solution.




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: In CVS Emacs, calc-eval gives multiplication higher  precidence than division
  2008-09-09 17:03                     ` Lennart Borgman (gmail)
@ 2008-09-09 17:19                       ` Stefan Monnier
  0 siblings, 0 replies; 45+ messages in thread
From: Stefan Monnier @ 2008-09-09 17:19 UTC (permalink / raw)
  To: Lennart Borgman (gmail)
  Cc: Carsten Dominik, emacs-devel, rms, Randal L. Schwartz

> Doing this then
>   8 / 2 * 2 = (8 / 2) * 2 = 8
> and
>   8 / 2 2 => 8 / (2 * 2) = 2

That's what I'd consider as The Right Way, yes.


        Stefan




^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: bug#914: In CVS Emacs, calc-eval gives multiplication higher  precidence  than division
  2008-09-09 14:36                       ` Francis Litterio
  2008-09-09 16:26                         ` Ulrich Mueller
@ 2008-09-30  4:10                         ` Leo
  1 sibling, 0 replies; 45+ messages in thread
From: Leo @ 2008-09-30  4:10 UTC (permalink / raw)
  To: emacs-devel

On 2008-09-09 15:36 +0100, Francis Litterio wrote:
> That would be me.  Sorry.
>
> But we should be prepared for more bug reports about this, unless some
> means can be devised to alert Calc users about the precedence rule.
>
> Would it be in appropriate to append a comment to the result when Calc
> is used interactively?

The current behaviour of calc is correct. All lecturers are using it
that way.

  ÷ has the same precedence as ×, but
  / has higher precedence over ×

Cheers,
-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .:  [ GPG Key: 9283AA3F ]  :.

        Use the better alternative -- http://www.openoffice.org/





^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2008-09-30  4:10 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-07 16:06 In CVS Emacs, calc-eval gives multiplication higher precidence than division Francis Litterio
2008-09-07 16:37 ` Jay Belanger
2008-09-07 18:15   ` Francis Litterio
2008-09-07 19:46   ` Stefan Monnier
2008-09-07 20:19     ` bug#920: " Lennart Borgman (gmail)
2008-09-07 20:32     ` Randal L. Schwartz
2008-09-07 20:34       ` Lennart Borgman (gmail)
2008-09-07 20:38         ` Randal L. Schwartz
2008-09-07 20:42           ` Lennart Borgman (gmail)
2008-09-07 20:50             ` Randal L. Schwartz
2008-09-07 21:07               ` Lennart Borgman (gmail)
2008-09-08  6:39                 ` Ulrich Mueller
2008-09-08  7:07                   ` Lennart Borgman (gmail)
2008-09-07 21:10               ` Stefan Monnier
2008-09-07 23:30                 ` Jay Belanger
2008-09-08  0:50               ` Jason Rumney
2008-09-08  1:13             ` Randal L. Schwartz
2008-09-08  3:47               ` Stefan Monnier
2008-09-08  8:48                 ` Miles Bader
2008-09-08 12:59                   ` Stefan Monnier
2008-09-08 13:29                   ` martin rudalics
2008-09-08  7:26               ` Lennart Borgman (gmail)
2008-09-07 21:10           ` Stefan Monnier
2008-09-08 10:30       ` Carsten Dominik
2008-09-08 11:01         ` Lennart Borgman
2008-09-08 20:33           ` Carsten Dominik
2008-09-08 20:39             ` Lennart Borgman (gmail)
2008-09-08 20:43               ` Randal L. Schwartz
2008-09-08 20:53                 ` Lennart Borgman (gmail)
2008-09-08 22:59                   ` bug#914: " Jay Belanger
2008-09-08 23:44                     ` Lennart Borgman (gmail)
2008-09-09 13:28                     ` Stefan Monnier
2008-09-09 14:36                       ` Francis Litterio
2008-09-09 16:26                         ` Ulrich Mueller
2008-09-09 16:41                           ` Lennart Borgman (gmail)
2008-09-30  4:10                         ` Leo
2008-09-08 21:42                 ` Stefan Monnier
2008-09-09  8:11                 ` Richard M. Stallman
2008-09-09 13:26                   ` Stefan Monnier
2008-09-09 17:03                     ` Lennart Borgman (gmail)
2008-09-09 17:19                       ` Stefan Monnier
2008-09-08 13:01         ` Stefan Monnier
2008-09-07 20:35     ` Jay Belanger
2008-09-07 21:15       ` Stefan Monnier
2008-09-07 21:19         ` Lennart Borgman (gmail)

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).