Hacker Newsnew | past | comments | ask | show | jobs | submit | stchang's commentslogin

Correct. More specifically, type checking is performed as part of macro expansion, which happens at compile-time.


Thanks for the comment!


The submitted link might be an older preprint.

Here is the official acm link to the paper: https://dl.acm.org/doi/10.1145/3371071


Awesome! Would love to check it out once you have a prototype.


It could, though it's not clear whether it would be an improvement.

Typed Racket uses macro expansion to translate its typed surface language into a typed core language, and then type checks that core language.

This approach works well because the surface and core languages are similar, and thus the type checker need only handle a small number of core forms.

This approach is limited, however, to constructs that are translatable into the core typed language. For example, a few Racket `for/X` comprehension forms are not supported in Typed Racket because they are difficult to translate.

Our approach alternatively uses macro expansion to type check the surface language and translates it into an untyped core language. Thus it's less limited in the typed languages one may implement. The tradeoff is that the programmer must implement type rules for all forms in the surface language, rather than just the core language.


Typed Racket uses macro expansion to translate its typed surface language into a typed core language, and then typechecks the core language.

Our approach uses macro expansion to typecheck the surface language and translates it into an untyped core language.

The two approaches should be considered alternative tools in a programmer's toolbox.


> Can you do dependent types?

Yes. For example, see https://github.com/wilbowma/cur


Minor correction, Matthias created Racket.


It's a misunderstanding that has unfortunately caught on among many Haskell programmers. People who say "macros are only useful in strict languages" mistakenly think that macros can only be used to delay evaluation. Of course, there are many more uses of macros, as you point out. Macros can define new binding forms, e.g., in Racket, pattern matching is a library, while it in Haskell it must be part of the core language. Macros are also useful for abstracting over non-first-class language forms like top-level definitions, import/export statements, and even type definitions.


FWIW, the phase system that is the main topic of the article was created for Racket [1], though some Scheme macro systems have since adopted this Racket innovation.

[1]: https://www.cs.utah.edu/plt/publications/macromod.pdf


Racket also has the concept of a documentation phase. Matthew Flatt wished it into existence when creating Scribble.



I think it (like Guile) just supports the reader syntax, rather than the semantics (which is heavily based on Racket's macro system).


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: