Remix.run Logo
rogue7 7 days ago

This looks neat. However since I read about Koka's dot selection [0], I keep thinking that this is an even neater syntax:

fun showit( s : string )

  s.encode(3).count.println
However, this is of course impossible to implement in most languages as the dot is already meaningful for something else.

[0] https://koka-lang.github.io/koka/doc/book.html#sec-dot

btbytes 7 days ago | parent | next [-]

It is called Uniform [Function] Call Syntax.

D has had this for decade(s): https://tour.dlang.org/tour/en/gems/uniform-function-call-sy...

Nim too has it: https://nim-by-example.github.io/oop/

jprafael 7 days ago | parent | prev | next [-]

That syntax is very clean when it works. I think however the limitation of not being able to pipe arguments into 2nd, 3rd, ..., positions and keyword arguments, or variadic explosion like the syntax showcased in the article makes it less powerful.

Are there other syntax helpers in that language to overcome this?

account42 7 days ago | parent [-]

It still makes sense to have a clean syntax for the simple case. You can use currying (with or without first class language support) to handle more complex cases or just fall back to good old function composition or even loops.

throw-the-towel 7 days ago | parent | prev [-]

I think this is called uniform function call syntax.