5 ms·
Crystal doesn't support a REPL yet because inferred static typing complicates incremental compilation. Blog: https://crystal-lang.org/2014/12/06/another-langua
by mshenfield 10y ago
Crystal doesn't support a REPL yet because inferred static typing complicates incremental compilation.
Blog: https://crystal-lang.org/2014/12/06/another-language.html https://crystal-lang.org/2014/12/06/another-language.html
Github Issue: https://github.com/crystal-lang/crystal/issues/681 https://github.com/crystal-lang/crystal/issues/681
- twblalock 10y agoScala has type inference with strong static typing, and a useful REPL. A Crystal REPL should be doable, unless Crystal's creators made some bad choices in the design of the type system that Scala's creators did not.
- mshenfield 10y agoMy 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...
- ekzy 10y agohere is an implementation https://github.com/greyblake/crystal-icr https://github.com/greyblake/crystal-icr
- mperham 10y ago`crystal play` is a pretty good replacement for a REPL.