In programming the "fluent" style programming has been adopted quite widely (cf.
<https://en.wikipedia.org/wiki/Fluent_interface>). It allows one to nicely code 
multiple
assignments/method invocations on the same object, by making sure that each 
such invocation returns
itself (the object in which the method gets activated) as a result, such that 
the next invocation is
working with the same object. This allows one to cascade method invocations. In 
ooRexx the double
tilde/twiddle "~~" allows one to employ this "fluent" style of programming as 
ooRexx will carry out
the appropriate mechanics.

Using the fluent programming style induces programming sequences like (C++ 
example from the above URL):

    FluentGlutApp(argc, 
argv).withDoubleBuffer().withRGBA().withAlpha().withDepth().at(200,
    200).across(500, 500).named("My OpenGL/GLUT App").create();

or (the same C++ program, better legible, i.e. easier to read/understand and 
less error-prone):

    FluentGlutApp(argc, argv) .withDoubleBuffer() .withRGBA() .withAlpha() 
.withDepth() .at(200,
    200).across(500, 500) .named("My OpenGL/GLUT App") .create();

It would be possible in ooRexx to define a class "FluentGlutApp" and invoke all 
the methods by using
the double twiddle message operator of ooRexx, yielding, e.g. an ooRexx program 
matching the above
C++ program:

    FluentGlutApp(argc, 
argv)~new~~withDoubleBuffer~~withRGBA~~withAlpha~~withDepth~~at(200,
    200)~~across(500, 500)~~named("My OpenGL/GLUT App")~~create

This is actually quite a powerful built-in feature of the ooRexx language. 
However, in order to make
the ooRexx programm better legible, one needs to break it up like:

    FluentGlutApp(argc, argv)~new - ~~withDoubleBuffer- ~~withRGBA- 
~~withAlpha- ~~withDepth-
    ~~at(200, 200)- ~~across(500, 500) - ~~named("My OpenGL/GLUT App")- ~~create

The code is better legible, however we have to add another operator to the end 
(a hyphen or a
comma). It would be easier to read, if it was possible to code in ooRexx:

    FluentGlutApp(argc, argv)~new 
~~withDoubleBuffer~~withRGBA~~withAlpha~~withDepth~~at(200,
    200)~~across(500, 500) ~~named("My OpenGL/GLUT App")~~create

Of course, in ooRexx it should be possible to intermix single message operators 
(~) and double
message operators (~) in such multiline message statements.

The rule would be for the parser that if the next line begins with a single or 
double message
operator, that it is regarded to be a split statement. If there are resulting 
errors, the normal
ooRexx error messages can be employed therafter.

---rony

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to