You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
About the nums:
for the language to work without types it's crucial not to have polymorphic overloading. In other words, +has to have type Fn(Int, Int) -> Int and +.has to have type Fn(Float, Float) -> Float.
In order to be able to calculate 1 + 1.2 it's enough to expose a function int_to_float : Fn(Int) -> Float so that we don't need extra concepts in the language (e.g. as). This is actually already implemented in the kestrel_core library - currently private
About the strings:
Didn't think about it! <> is the str concat in elixir so I just went with this
But maybe ++ might be more natural 🤔
Update 1: <> was changed into ++
Update 2: A simplified version of Haskell's type classes was introduced in #25. So far only the trait Show, Eq and Ord are included, but a Num type classes might be defined too, in order to solve the +, *, etc overloading problem.
Lang tour
Math ops
For UX reasons, it would be better to not duplicate the math operators.
There are 2 possible better alternatives.
1. Overload operators (Rust, Elm)
Attempting to sum an Int with a Float is a compile time error.
An explicit cast is required to sum integers
2. Numeric promotion (Java approach)
In Java 1.0 + 2 Returns 3.0.
Numbers are automatically promoted, when necessary, in binary ops.
See 5.1.3 Narrowing Primitive Conversion
String concat operator
In SQL
<>
is the not equal operator.It's confusing to use it for string concatenation.
Either +, ++ or :: are better alternatives.
The text was updated successfully, but these errors were encountered: