Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> In Lisp a procedure tends to accept many options which configure its behaviour. This is known as monolithism, or to make procedures like a kitchen-sink, or a Swiss-army knife.

This is the case in some areas of the Common Lisp language; it is not true of the Lisp, as a family of dialects.

There are plenty of examples of Lisp functions or operators that just do one thing: `cons`, `car`, the `lambda` macro operator.

   ;; CL
   (remove-if-not #'p xs :count 5 :start 3)

   ;; Haskell
   take 5 . filter p . drop 3

   ;; TXR Lisp: a dialect with ties to CL:
   (take 5 [keep-if p (drop 3 list)])

   ;; Compose the functions using opip macro
   ;; (result is a function object):
   (opip (drop 3) (keep-if p) (take 5))
TXR Lisp's library functions don't have the :count, :start and whatnot. In fact, there are no keyword parameters, only optionals. If you want to default an optional on the left and specify a value of one on the right, you can pass the colon keyword to explicitly default:

   (defun opt (a : (b 1) (c 2)) ;; two optional args
     )

   (opt 4 : 5)  ;; b takes 1, c takes 5.
The colon is just the symbol whose name is the empty string "", in the keyword package. It makes for nice sugar and has a couple of uses in the language. Note how in the defun it separates required args from optionals.

(Anyone else cringe at "UNIX philosophy"; how silly! This is the Unix philosophy: let's reduce everything to a string in between processing stages and parse it all over again, with simplifying assumptions that it always has exactly the format we are looking for without actually validating it.)



That's the JWZ perspective, but if you add strong typing you can basically turn the "string" into "SomeType" and process records like that. If you look at languages with a |> operator they often act like that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: