Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pure OO vs. Curried Syntax

Name: Anonymous 2010-08-07 23:18

So /prog/, I have looked around and I haven't been able to find any more-or-less pure OO languages with curried syntax. What gives?

It's not uncommon to see: object message message message

Where object message returns an object which accepts takes the next message, but what if the message is a method call that takes parameters? Instead of returning a curried object, you still get: object method(a,b) method(x,y), but never: object method a b method x y -- why is that?

Name: Anonymous 2010-08-10 0:09

>>29
I have looked at it, but AFAIK OCaml doesn't provide a means to curry messages. Admittedly I haven't gotten too deep into it so I can't say with absolute certainty.

I have isolated a point of ambiguity that is possibly inescapable without adding syntax that causes the convenience benefits to evaporate; consider the following:

w x y

Suppose w is an object, according to the premise. x is a message, but is it the name of a method on w or is it a value to be supplied (where and how should it be evaluated?) Since all objects can be assumed to be happy to receive more messages, we can't simply consider whether w is a closure wanting more arguments since it's still an object and all objects appear the same in this regard (and arguments are being supplied as messages.)

Going along, suppose we decide we'll take whatever we can get. If x is a valid message (i.e. w contains a slot/property/member named 'x'), it will be treated as such. If not, it will be evaluated in the caller before being passed on. The problem of ambiguity arises when x qualifies as both. You can assign priority (probably to the caller), but you may want to use the alternative (eg. in the callee.) A simple '.' prefix might specify that x is intended as a message name: w .x y

Which is suspiciously similar to: w.x y

Which is precisely regular curried syntax with functions (in the event that w's x is a method accepting a single argument.)

As long as everything is an object I don't think there's a solution that ties everything up nicely. The surface landscape simply needs more variety. On the other hand, in the examples above it's likely that w .x y would be required only rarely and it might be usable if you don't mind seeing a sea of words without much (if any) punctuation of any kind.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List