Remix.run Logo
xigoi 6 days ago

Janet, like some other lisps, has the arrow macro, which allows you to write in the “OO” style.

  (-> a (fun b c))
zelphirkalt 5 days ago | parent | next [-]

Ah neat! In Guile I use threading/pipelining all the time with a small macro:

    (define-syntax ->
      (syntax-rules ()
        ;; first expression is left unchanged
        [(-> expr) expr]
        ;; take from the back, wrap other calls
        [(-> expr* ... (op args* ...))
         (op args* ... (-> expr* ...))]
        ;; make parens unnecessary in trivial case of no further arguments
        [(-> expr* ... op)
         (op (-> expr* ...))]))
Janet already having this ... Reading many good things about Janet in this discussion.
uvas_pasas_per 6 days ago | parent | prev | next [-]

Something like this combined with some IDE smarts to offer up the possibilities for `fun` after I type `(-> a` ... that could be very cool.

terminalbraid 6 days ago | parent [-]

You mentioned autocompletion a few times and that is something available via LSPs (janet specifically has one that has this) or through the editor (e.g. emacs can use swank for common lisp). It's no different for any other language integration.

worthless-trash 5 days ago | parent | prev [-]

I think that threading macros is different to method chaining (at least to my understanding), method chaining works on the object returned, and threading macros can work on raw data or objects.