3 ms·
My intuition is also that a Crystal REPL is technically possible. But FTR, the two languages implement subtly different type restrictions. Scala has type infer
by mshenfield 10y ago
My intuition is also that a Crystal REPL is technically possible. But FTR, the two languages implement subtly different type restrictions.
Scala has type inference, Crystal has optional typing. In Scala, there are certain situations when the type is discernible by the compiler, and can be omitted. For example
val x = 1 + 2 + 3
the compiler infers that x is an Integer. However, omitting type information in Scala is the exception not the rule. Methods and functions, for example, must have type annotations.
In practice, Crystal also infers type. But in Crystal you can omit almost any type annotation, including method and function definition. This probably poses a different challenge for the compiler authors. The Type Restrictions sections provides some more examples https://crystal-lang.org/docs/syntax_and_semantics/type_restrictions.html https://crystal-lang.org/docs/syntax_and_semantics/type_rest...