Closed GreasySlug closed 2 years ago
I think it is unnecessary to bother writing about the arithmetic operations in the syntax documentation.
It is better to write in the documentation under the API what specific operators are defined.
It is better to write in the documentation under the API what specific operators are defined.
Well, that may be true, but four arithmetic operations and comparisons are often used in "quick tour" and "getting started.
Erg’s type conversion is also strict, but has the flexibility of subtyping by trait or class.
This is exactly the kind of thing that should be explained in detail in the API.
For example, given the operation 1.0 + 1, the 1 on the right-hand side is cast to instance 1.0 in the superclass Float; the addition of Float and Float is defined, but the addition of Int and Float is not directly defined.
so the examples are incorrect and I will fix them
Quick tour doc exists: https://github.com/erg-lang/erg/blob/main/doc/EN/syntax/quick_tour.md
I'll move this to the beginning of quick tour.
Is anything wrong with this except for the casting of the type?
True and False are singletons of type Bool.
Casting them to Int yields 1, 0, but they are not defined as 1, 0.
Bool operations are performed with and
, or
, and not
. &&
, ||
, and ~
are bitwise operators.
Quick Tour link added in the Basics section. I removed the basic four arithmetic operations and comparisons because it is written not to write them if the contents are duplicated in python. However, compile errors due to type are left untouched.
Since Bool
is a subtype of Int
and Int
is a subtype of Ratio
(although the current implementation is Float
), True
can be cast to 1.0
.
However, Float
cannot be compared by ==, so a compile error will occur.
Float
cannot be compared by ==, so a compile error will occur.
The reason for this is that Float does not satisfy the transitive law, which is the condition for equivalence relations.
Thank you for reviewing
Thanks!
Related #178.
Four arithmetic operations, comparisons, and logical operations were missing, so those were added in Japanese.
Once this has been reviewed, then I' ll translate it into English and add it later.
@mtshiba