On Friday, June 30, 2017 at 6:59:27 AM UTC+2, johnbclements wrote: > > On Jun 29, 2017, at 17:33, Zelphir Kaltstahl <zelphirkaltst...@gmail.com> > > wrote: > > > > A while ago I started looking at Typed Racket and today I took a look again. > > > > The documentation says: > > > >> Typed Racket provides modified versions of core Racket forms, which permit > >> type annotations. Previous versions of Typed Racket provided these with a > >> : suffix, but these are now only included as legacy forms for backwards > >> compatibility. > > > > To me this sounds as if I am not supposed to use them anymore. So I tried > > the following, which works: > > > > ~~~ > > racket -I typed/racket > > > > (let ([x 7.0]) > > (ann x Positive-Flonum) > > x) > > ~~~ > > > > So I could use `ann` instead, but is it not as short as the colon notation. > > Then I also discovered: > > > > ~~~ > > (let ([x 7.0]) > > (: x Positive-Flonum) > > x) > > ~~~ > > > > Which also works. It is not a change in a core form, so I guess this is not > > part of the stuff kept for backward compatibility (?). > > > > I'd like to know what the best practice of writing type annotations is. The > > guide in the documentation still uses a lot of the changed core forms, > > which is my impression are not recommended, since they're only kept for > > backwards compatibility, so one should not rely on them. > > I believe this text is referring to forms such as for: and lambda: — that is, > syntactic terms where the lambda is attached to the identifier. I believe > this text is *not* referring to the use of the colon as a simple “has-type” > form. > > John
Hm that could be it! I was already wondering why it was talking about "suffix" instead of "infix". I was assuming it meant suffix because it is after the first element of the s-expressions and it was a comment next to where those were introduced. Ok but what is the best practice? Using: ~~~ (ann a Type) ~~~ ~~~ (: a Type) ~~~ ~~~ (a : Type) ~~~ and when? For example in a let form, I could imagine that it might be best practice to specify the type where the variable is specified, instead of a new line and a new s-expression. But I'd like to read some reasoning or guide from someone who knows a lot about Typed Racket or maybe even worked on it. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.