logoalt Hacker News

cptrootyesterday at 8:43 PM1 replyview on HN

Good news, there's a line in the "Coming from Rust"[1] page that says

> You never annotate a function signature unless you want to for documentation purposes.

so it sounds like function annotation is still an option for the purposes of communication, just no longer required in all cases.

[1] https://loonlang.com/concepts/from-rust


Replies

cptrootyesterday at 9:06 PM

Aha, here's the syntax in case you're curious (using an example lifted from the playground)

  [type Shape
    [Circle f64]
    [Rect f64 f64]
    Point
  ]

  [sig test_sig : Shape -> Float]
  [fn test_sig [shape]
    [match shape
      [Circle r] [* 3.14159 [* r r]]
      [Rect w h] [* w h]
      Point 0.0
    ]
  ]
Unfortunately it seems like this doesn't currently work as expected when I use it in the playground, so I'm going to go file an issue
show 1 reply