Ancestors

Toot

Written by Olical on 2025-01-21 at 14:00

Fennel functions created with the lambda keyword throw a runtime error if given a nil argument unless the name is prefixed by ? - super useful!

(lambda [x ?y z]
  (print (- x (* (or ?y 1) z))))

In this case, x and z are required, y can be nil.

=> More informations about this toot | More toots from Olical@mastodon.social

Descendants

Written by Olical on 2025-01-21 at 14:02

The tail! marker gives you compile time checking that you haven't broken a tail call!

(fn process-all [data i]
  (case (process (. data i))
    :done (print "Process completed.")
    :next (process-all data (+ i 1))
    :skip (do (tail! (process-all data (+ i 2)))
;;             ^^^^^ Compile error: Must be in tail position
              (print "Skipped" (+ i 1)))))

=> More informations about this toot | More toots from Olical@mastodon.social

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113866706066155471
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
235.147527 milliseconds
Gemini-to-HTML Time
0.733405 milliseconds

This content has been proxied by September (3851b).