>
>
>    - How stable is your implementation of extensions? Are there any
>    unexpected side-effects to be expected?
>
>
The only thing I implemented is the ::extension directive which delegates
to the methods 'define' and 'inherit'.
 The core implementation was already in place in the interpreter. I had
just to unlock the 'define' and 'inherit' methods, to let them work on
predefined classes. And to allow propagation of the extensions to existing
instances (seems more work is needed here) :
- An extension made on .Object is not available on a class.
- An extension made on .Object is not available on the .nil object.
That's why I asked a big picture for metaclasses, classes, instances a few
weeks ago. But I had no time to investigate.

So far, I don't see unexpected side-effects.


>    - How can one achieve the following extension (from "extensions.cls")
>    directives dynamically at runtime (e.g. if one creates a method object for
>    the 'quoted' method at runtime, how could one use that to extend the
>    .String class at runtime) ?
>
>     ::extension String
>
>    ::method quoted
>        use strict arg quote='"'
>        return quote || self~changeStr(quote,quote||quote) || quote
>
>
>
 .String~define("quoted", "use strict arg quote='""' ; return quote ||
self~changeStr(quote,quote||quote) || quote")


>    - How is it possible to learn which methods got extended in a class?
>
>
To my knowledge, not possible  (is it possible to know which methods were
incorporated specifically with define ?)
You can query the methods inherited by extension, but there is nothing
specific to extension here.
Ex :
::extension String inherit StringDoer StringReducer StringMapper
StringRepeater StringIterator
10~instanceMethods(.StringRepeater)=
    #     1: index=[UPTO]         -> item=[a Method id#_540414686]
    #     2: index=[YIELD.DOWNTO] -> item=[a Method id#_540524136]
    #     3: index=[TIMES.YIELD]  -> item=[a Method id#_540396602]
    #     4: index=[TIMES]        -> item=[a Method id#_540379280]
    #     5: index=[DOWNTO]       -> item=[a Method id#_540478658]
    #     6: index=[YIELD.UPTO]   -> item=[a Method id#_540460386]


>    - What happens, if different programs extend a class with a method by
>    the same name? Is this allowed, and if so what are the rules (each
>    extension method replaces an exisiting extended method; or it is an error
>    to extend a method, if the method exists already)?
>
>
The rules are those of 'define' and 'inherit'.
Currently, the only case of error is when the same method appears several
times in a given::extension directive. It's like that because I duplicated
the code for ::class.
It's possible to extend a class several times in a same package.
It's possible to extend a class in different packages.
If the same method appears in different ::extension directives for the same
class, there is no error.
During parsing, the extensions methods of an  ::extension directive are
accumulated in a table (todo : use an ordered collection). The 'inherit'
declarations are accumulated in a list. When the extensions of a package
are installed, the extension methods and the inherit declarations of each
::extension are processed in the order of accumulation.
If the same method appears in several ::extension directives, then the most
recent replaces the older (because 'define' works like that).
Each package is installed separately, this is the standard behaviour. The
visibility rules for classes are also standard, nothing special for
extensions. Each package has its own visibility on classes.

http://oorexx.svn.sourceforge.net/viewvc/oorexx/sandbox/jlf/samples/extension/test_extension_order.rex?view=log

Todo : forbids to replace a predefined method. The goal is to extend, not
to alter the behavior. Maybe not so easy to do for 'inherit'.

>
>    - Is it possible to remove an extended method later in the program? If
>    so, how?
>
>  .String~define("quoted")
Todo : forbid to remove a predefined method.


Jean-Louis
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to