4 ms·
Older language designers seem to have held natural language as their ultimate syntax, so reserving keywords would be anathema to that goal. It's probably also i
by Retra 9y ago
Older language designers seem to have held natural language as their ultimate syntax, so reserving keywords would be anathema to that goal. It's probably also in direct conflict with efficient parsing. And you still see some people thinking along the same lines when they obsessively over-value "DSL"s and
like().writing(all.their.code()).like(*this)
In which case, the programmer doesn't have to memorize keywords, but they do have to memorize these obscure, unpredictable, and noncommunicable features of where to properly put their dots and parens. Which is far worse, in my opinion.
- seanmcdirmid 9y agoThat is called a fluent interface (https://en.wikipedia.org/wiki/Fluent_interface https://en.wikipedia.org/wiki/Fluent_interface) and is generally frowned on by experienced language and API designers (even of the OO variety). It has nothing to do with language keywords, it is just too far away from operational behavior to be very readable or debuggable.
- kazinator 9y agoIt looks like "fluent interface" resembles "point-free" programming: https://en.wikipedia.org/wiki/Tacit_programming https://en.wikipedia.org/wiki/Tacit_programming However, there seems to be a key difference. Under "fluent interface", it looks like the object context is pointlessly being chained and the operations are just side-effecting on it, whereas "point free" programming implements a transformation pipeline by chaining side-effect-free operations. E.g. turtle.rotate(90).pen_down().forward(5); Kind of thing which isn't a pipeline at all, and could be written: turtle.rotate(90); turtle.pen_down(); turtle.forward(5); and arguably should.
- b2gills 9y agoI think using some sort of construct that topicallizes the object is a good middle ground between the two. For example this Perl 6 code: with turtle { # store in topic variable $_ (if it's defined) .rotate(90); # implicit method call on $_ .pen_down(); .forward(5); }
- Retra 9y agoNo it's not about keywords, but about jumping through fiery hoops to create code that sounds like natural language when you read it out loud.