(j3.2006) Chaining type-bound procedure references
Malcolm Cohen
malcolm
Wed Apr 30 19:37:13 EDT 2014
<<<
On several occasions, and today in particular, I have encountered the situation
where it would be clearer (and definitely easier) to implement an algorithm in
the following fashion:
val = obj % method1() % method2()
Here method1() returns some object, and method2() is bound to class of that
object. And I realize of course that the language does not (currently) permit
anything like this.
>>>
INTERFACE method2
MODULE PROCEDURE do_method2_on_something
END INTERFACE
FUNCTION do_method2_on_something(something) RESULT(r)
declare the result
CLASS(someobject) something
r = something%method2
END FUNCTION
val = method2(obj%method1())
Yes this "pollutes" the namespace slightly, and you *might* need a helper
function (though the way we've done object orientation you can have a single
function that will be both a normal function and type-bound) but the invocation
is simple.
<<<
I can guess that there are some inherent ambiguities that make my syntax above
non starters, though I cannot readily think of what the are.
>>>
I don't think we can do this without opening the floodgates to
func(...)%component
which we decided against doing long ago.
And it does seem like a pretty big feature that does little more than provide
alternative syntax for something we can do easily already.
Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list