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 14:11

>>35
I had assumed that a message was some first class value that was dispatched upon to return either another value and that in your examples 'message' could conceivably be any legal expression of the language that returned a message.
I did mention (I think) that messages were to be objects. I don't think using an expression in place of 'message' changes anything, although you would have to signify evaluation.

Yuck
Of course. It's just an example. It's also common in my experience, with the happy coincidence that the problem with it almost never arises. (This is why I started with this example, then reversed it by the end of the paragraph. If there is a conflict it is easier on the programmer if the caller has the preferred ground.)

I see the problem, you wanted to treat a message as any other identifier.
It's a good way of putting it. I fully admit to introducing a confusion. It took me a little longer than it should have to realize that without extra syntax or extreme measures of some kind, there is no way back to stable ground when the language permits that kind of conflict.

Speaking of extreme measures, I had considered message objects with special (i.e. semantically relevant) properties. Unbound identifiers could easily be considered message constructors. It's an organic version of the 'preferred caller' solution.

Which is precisely regular curried syntax with functions
Which is what you wanted, right?
Well, not quite. Function currying is common. It's when messages are thrown in to the currying process that I am interested in. I do have that with some caveats and I would be satisfied with w .x y, except that much of the goal is to eliminate method call syntax. On the other hand, that form is only really needed in certain cases (eg. when the caller is subject to change, though this might fall under "maintainability" too) and it does seem like it helps even if it's not everything that was desired.

The OCaml examples don't immediately help because it should all be implicit. I didn't really make this clear, and I guess I should have. On the other hand: (bar#make_added 4 3)#get;; is not bad, but too bad about the parens. In a serious language this is probably the better way to do it anyway, and you wouldn't catch me complaining about having to use this.

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