Issue-#147 Fraction function in System Math

Merged to the master branch
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Issue-#147 Fraction function in System Math

Post by Robert »

Josef Templ wrote:Mod1 has the advantage that it documents pretty well what it does.[
I agree.
In C libraries the function "fmod()" is quite common for floating point
modulo operations. And our function is exactly fmod(x, 1).
I disagree with the reasoning, but agree with the conclusion - which is probably what matters.
To me a good reason is that it closely resembles the Component Pascal function "x MOD 1".

Doug - do you really want to continue this discussion? I would rather keep it short.
Look at http://mathworld.wolfram.com/FractionalPart.html for a typical neutral discussion of this area. Both functions are widely recognised,
but there are not commonly agreed dual names; "Frac" is widely used for both. To provide both functions we need to invent a new name, which is undesirable.
Josef's suggestion is clever because he has avoided that by reusing, without misusing, an existing name.
---
Just to clarify: When I say I disagree with the reasoning I do not mean to imply it is wrong, merely that it does not convince me to support the conclusion.
Personally I don't care what a particular C library does.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: Issue-#147 Fraction function in System Math

Post by Josef Templ »

Robert wrote: The proposed text includes comparisons with 10^16, which has nothing to do with either the meaning or implementation of the new function.
Robert, I am sorry but you missed an important property of ENTIER.
The comparison IS important. Please, try it out.
The docu says that it is easy to implement the functions with ENTIER but the
truth is that it is is not completely trivial. You must take the possible overflow into account.
This is shown in the code.
Robert wrote: I do not want to discuss this forever. This text is just a useless distraction, and we would all be better off if it were deleted.
Nobody wants to discuss this forever.
The simplest way to proceed is to focus on the issue at hand (add a function) and
follow existing conventions.
Deleting a large part of text where we don't know exactly if it removes important information
is not part of this issue and makes the discussion complicate.
Robert wrote: Take ArcTanh as another example: the text (which includes four variants) does not help clarify the meaning of ArcTanh. And why should there be such text? - there is no (hidden) text that attempts to clarify the meaning of Exp, is that an omission that should be rectified?
My interpretation is that this code is also intended as a kind of "porting guide"
where it is shown how the "extended" functions can be based on a small set of
"basic" functions plus CP language features, unless a more efficient implementation
is available.
The small set of basic functions is exactly the set of functions in the
original Oberon Math library. It is of course not possible to define basic functions (like Exp)
by means of other functions.

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Issue-#147 Fraction function in System Math

Post by Robert »

Josef Templ wrote:Robert, I am sorry but you missed an important property of ENTIER.
We are still talking at cross-purposes.
I am not saying that the alternative functions are wrong.
I am not saying that the small ArcCosh difference is significant to the user.
I am not saying that the alternative Mod1 would work without the 10^16 comparison.
I am not saying these alternatives are worse than the actual code - I don't know and don't want to investigate.

What I am saying is:
- They are different to, and thus do not describe, the existing code.
- I also know that the author of this module decided that the existing code was preferable 20 years ago (because he chose to use it).

Now if someone (in a sparate issue!) were to give a reason why a new implementation, of any of the functions, had significant advantages I would be prepared to look at that.
But in the meantime the relevance of this text has not been explained, and I think it is a distraction.

We can treat extending, moving, or removing it as a separate issue. I will not start that issue myself.
Ivan Denisov
Posts: 1700
Joined: Tue Sep 17, 2013 12:21 am
Location: Russia

Re: Issue-#147 Fraction function in System Math

Post by Ivan Denisov »

Josef, the Docu should go here in one issue. We should not make another Docu issue for this feature.

Docu section is used for improvement of some documentation or for adding some without changing the sources files. So the documentation for Mod1 should be discussed here also.

I am also do not like Mod1, IMHO, better name is FractionalPart or FracPart.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: Issue-#147 Fraction function in System Math

Post by Josef Templ »

It is sufficient to add an explanation of the alternative code such as:

"The following code shows how to implement a large part of the module Math
on top of a small set of basic functions and Component Pascal language features.
This may for example help to port the module to another platform."

This does not go far beyond our issue.
This does not remove potentially valuable information.
This is very simple.

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Issue-#147 Fraction function in System Math

Post by Robert »

Josef Templ wrote:It is sufficient to add an explanation of the alternative code such as: ...
Thats ok by me.
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Issue-#147 Fraction function in System Math

Post by Robert »

Ivan Denisov wrote:I am also do not like Mod1, IMHO, better name is FractionalPart or FracPart.
These suggestions suffer the same problem as my original suggestion "Fraction"; the new name and the old name "Frac" do not usefully identify the different behaviours of the new function and the old function.
They have two further disadvantages:
- The fact that the new name includes "Part" and the old one does not makes one think that "Part" must go some way to explain the difference, but it does not, so that is misleading. With my suggestion there are no clues, so you immediately know you have to go to the Docu for explanation.
- These names are longer. These functions are often used as part of complex mathematical expressions, which are easier to read if they are short, and fit on one line. This is, in fact, a serious consideration.

So I still think Mod1 is an ingenious solution, and the best so far.
User avatar
Josef Templ
Posts: 2047
Joined: Tue Sep 17, 2013 6:50 am

Re: Issue-#147 Fraction function in System Math

Post by Josef Templ »

> These suggestions suffer the same problem as my original suggestion "Fraction";

I agree with Robert.
The alternatives proposed so far are not convincing.

We still have a merge conflict on System/Rsrc/Strings to resolve.
Robert, if you don't mind I can do the conflict resolution.

- Josef
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Issue-#147 Fraction function in System Math

Post by Robert »

Have we discussed names enough? If I call another poll will people vote against the name "Mod1"?
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Issue-#147 Fraction function in System Math

Post by Robert »

Josef Templ wrote:>We still have a merge conflict on System/Rsrc/Strings to resolve.
Robert, if you don't mind I can do the conflict resolution.
Josef
The second part of my "Plan A" for dealing with this was to manually incorporate the other changes into this Strings file, then tell Git to do an override merge - I think that is an option. To answer your question about the omitted blank line, that was an accident. I was using F9 to compare files, and neither it nor I saw it.
The first part of my Plan A was to ask you if there was a better technique.

I am quite happy to go with "Plan B"; let you do it. With your wider experience it is probably easier for you than me.
Post Reply