3 ms·
There's a few caveats [0] compared to untyped Racket, optimisation can be a little trickier, type generalisations can be somewhat unexpected. Typed/untyped boun
by shakna 9y ago
There's a few caveats [0] compared to untyped Racket, optimisation can be a little trickier, type generalisations can be somewhat unexpected. Typed/untyped boundaries can be unexpectedly expensive at times.
But the big one compared to Haskell is:
> Typed Racket will type-check all expressions at the run-time phase of the given module and will prevent errors that would occur at run-time. However, expressions at compile-time—including computations that occur inside macros—are not checked.
[0] https://docs.racket-lang.org/ts-guide/caveats.html https://docs.racket-lang.org/ts-guide/caveats.html
- tomjakubowski 9y agoI misread this sentence the first couple times. Note that it isn't saying that Typed Racket only catches type errors at runtime, i.e. that it's a runtime type checker or a "contracts" implementation; it's saying that it—statically, and ahead of time—checks that expressions that would be evaluated at runtime have the correct types. (NB: as the caveats section notes, macro expansions are still statically type checked in Typed Racket) What makes you see this as a caveat relative to Haskell? I can't imagine most Racket users typically deal with macros at such a low level; don't Schemers tend to use syntax-rules? https://docs.racket-lang.org/guide/proc-macros.html https://docs.racket-lang.org/guide/proc-macros.html
- shakna 9y agoUsing things like begin-for-syntax for compile-time evaluation isn't unusual for things like optimisation, but it'd bypass Typed Racket's safety here. And usually, you don't need to care if what you're calling is a macro or a procedure. Now you do.
- alphaalpha101 9y ago>And usually, you don't need to care if what you're calling is a macro or a procedure. Now you do. You always do, because macros can change evaluation semantics and procedures cannot.
- wtetzner 9y ago> but it'd bypass Typed Racket's safety here. Sort of, but the expansion of any macros is still type-checked.
- samth 9y agoIt doesn't bypass safety -- all code that's actually run is typechecked. It's just that we don't enforce anything about the macro itself, so the macro might error or produce code that results in a type error.