News for hackers. Stuff that matters.
Re:Your programming language is probably unproductive by kazinator on Wednesday September 28, 2016 @10:46AM (#12598041)
Counterpoint to the remarks about braces and partial application:

Implicit partial application is a poor idea that makes programs incomprehensible. If you pass only three arguments to a four-argument function foo, you should see a "foo: insufficient arguments" error, and not a function of one argument popping out.

The semantics of obtaining a partially applied function doesn't depend on syntax. It can work fine when function arguments are delimited by parentheses. For instance, suppose that if we write (cons 3) we automatically get the equivalent of (lambda (x) (cons 3 x)). That's partial application, with parens. We can then do (mapcar (cons 0) '(1 2 3)) and get ((0 . 1) (0 . 2) (0 . 3)). Is that a good idea? Firstly, we lose variadic functions and functions with optional arguments. (list 0) can't return a lambda; it already has a meaning; (list) produces the empty list, (list x) a list of one element which is the value of x, and so on. We could end up with an embarrassing proliferation of fixed arity functions like list1, list2 and list3.

It's not that much of a chore to have an explicit partial application operator: Say:

   (op list)     -> (lambda (. args) (apply list args))

   (op list _ 1) -> (lambda (arg) (list arg 1))
If that is too verbose, and used often, we can dedicate alternative closure punctuators to it:

   {list}        ->  (op list)

   {list _ 1}    ->  (op list _ 1)
So braces now help with partial application, enabling it when we want it. The notation keeps code crystal clear because everything is delimited. We know that (op foo 1 2 3) or {foo 1 2 3} partially applies exactly three arguments to foo, no more or less, and we know that (foo 1 2 3) calls foo with exactly three arguments.

There are no comments on this comment yet.