On Tue, May 18, 2021, 8:07 AM Steven D'Aprano <steve@pearwood.info> wrote:
What's the actual problem you are solving with this complex, complicated
proposal? In other words, what is the motivation? You mentioned symbolic
maths in the previous thread.

It seems to me the motivation is only related to looks insofar as it makes it a little more convenient to not lose information when writing expressions, which also happens to have the side benefit of looking a little better.

What is so special about constant expressions like `1/3`? Why shouldn't
non-constant expressions like `one/three` work?

I'm also interested in this question. 

If one/three is a float at compile time, you're going to have an ugly situation where:

Fraction(1/3)

and:

Fraction(one/three)

Result in different values? If not, then how is this avoided...?


You say:

> All of this does not only work for integers, but also for float
> literals

and give 0.1 as an example. Okay, I will grant you that *most* people
will expect that 0.1 is 1/10, rather than
3602879701896397/36028797018963968 but what about less obvious examples?

If I write 0.6666666666666666 will I get 2/3? What if I write it as
0.6666666666666667 instead? (They are different floats.) How about
0.666666666667, copied from my calculator?

How about 0.66667? Is that close enough to get 2/3? Its obvious that in
real life anyone writing 0.66667 is thinking "2/3".

I think the point here is actually the reverse: you can't create the actual value of 2/3 using any currently available literal.

Some "fractional literals" (speaking about these in mathematical syntax, not python syntax) such as 1/10 can also be exactly represented as a "decimal literal", 0.1. You said most people would expect the actual value of 1/10 when seeing 0.1, but I'd be interested in meeting people who expect something else.. I'm assuming here that most would at least would LIKE to be able to be able to expect 1/10 IF it doesn't cost them too much in some other way. That seems uncontroversial.

The fact that this it isn't possible to represent 2/3 using "decimal literal" in mathematical language isn't a shortcoming of the proposal, it's just a shortcoming of written math in a base 10 system. N other words the proposal isn't trying to create a way to magically guess what the real value is MEANT by the user in their mind; on the contrary, it is intended to try to better preserve to WRITTEN INTENT of the user, mapped to standard mathematical syntax.

I'm not against or for it yet mind you, but I don't see this as really a big objection.