Skip to content

Comment on Keyword Arguments: Ruby, Clojure, Common Lisp

Comments

I've never found a situation where keyword arguments are a better choice than setters. Setters are dynamic, you can override their implementation. Keyword args only let you override the method that receives them, which provides less granularity and leads to duplication (assuming there is more than one method that accepts a shared arg).

I've never found a situation where keyword arguments are a better choice than setters.

When you're programming in a functional style, perhaps? The idea of a setter doesn't make much sense in Clojure where the native data structures are immutable, implementation inheritance is strongly discouraged and state changes require a little more work than "x = y".

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.