Hacker News new | past | comments | ask | show | jobs | submit login

> the implicit operator in a sequence of two expression without parentheses could be string concatenation rather than function application

You can design a language which uses `e1 e2` to represent any binary operation you like, but I'd argue that function application is more common than string concatenation, so it's more deserving of that syntax. Plus, it plays nicely with currying.




I’ve sometimes thought that a reasonable alternate choice would be:

  f g = composition of f then g
  x.f = f applied to x
  x.f g h = in regular notation h(g(f(x))
Though slightly different precedence rules may be preferable.

I think the k in awk considered juxtaposition-as-string-concatenation to have been a mistake by the way.

Some other reasonable choices may be:

- disallowed syntax

- multiplication (which, for matrices, is a special case of function composition and application)

- inner join which can be seen a bit like function composition but for relations instead of functions

- sequencing (ie instead of ‘;’)


That's an interesting idea, but how does it work for functions of multiple arguments?

If functions are curried, then I suppose the syntax for `f x y` would be `y.(x.f)`, which maybe you could write as `y.x.f` if the associativity worked as such. But that means you have to provide your arguments in reverse order?

If functions are not curried, do you write `(x, y).f`?




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

Search: