|Feedback for compiler project email@example.com (2001-09-20)|
|Re: Feedback for compiler project firstname.lastname@example.org (Joachim Durchholz) (2001-10-06)|
|Re: Feedback for compiler project email@example.com (2001-10-10)|
|Re: Feedback for compiler project firstname.lastname@example.org (Joachim Durchholz) (2001-10-12)|
|Re: Feedback for compiler project email@example.com (2001-10-12)|
|Re: Feedback for compiler project firstname.lastname@example.org (2001-10-13)|
|Re: Feedback for compiler project email@example.com (2001-10-13)|
|From:||firstname.lastname@example.org (J.van Iddekinge)|
|Date:||13 Oct 2001 23:10:16 -0400|
|Posted-Date:||13 Oct 2001 23:10:16 EDT|
email@example.com (VBDis) wrote in message news:01-10-050...
> firstname.lastname@example.org (J.van Iddekinge) schreibt:
If I look at the reaction of mine post, i think i need some more
explenation of what dynamic routines are. I had hoped that the text
somewhere at the Elaya home page (www.elaya.org) was enough. Please
look at the following text and give feedback. (This text is only a
small part, first i want feedback on this text)
For understanding what Dynamic Routines are, just look at the
name. Dynamic Routiesare << Routines >>. They have nothing todo with
Objects/Classes. The only relationship with object/classes is the
same as normal routine/methods have with oop. Normal routines can be
used in procedural programming and as methods in classes. The same is
valid for dynamic routines. Next follow examples , wich show what
dynamic routine are used in procedural sitation. Forget everthing
about objects for a while. First if we look at a normal routine in
procedural programming, wich displays a file(In pascal):
procedure ShowTextFile(ParFileName : string);
vlFile : text;
if ioresult <> 0 then exit;
while not(eof(vlFile)) do begin
if ioresult <> 0 then break;
A routine wich access a file looks follow nearly the same sequence of steps:
2) Do something
(It is also necessary to add some error checking, wich in many cases
isn't done properly.) All file operations follow above 3 steps. Every
time we must program the open the fileand close the file and code the
error checking. When normal routines are used we must program all
these steps. For this type of operation we can also use dynamic
procedure ProcessTextFile(virtual ParFileName :string);root;
function ReadLine(var pArStr):boolean;
if ioresult <> 0 then exit(true);
if ioresult <> 0 then begin
end else begin
if DoSomeThing then Error;
The routines 'Readln', 'DoSomeThing' and 'Error' are defined inside
the routine 'ProcessTextFile'. These routine are only visible inside
the routine, and can access local variabels and the parameters. It is
not necessary too pass the a file variable when using readln, because
it can directly access the 'vlFile'.
Whe can now define a new dynamic routine, wich is based on above.
This is also done by 'inheritation'. When used in a dynamic routine a
new routine is created based on the parent routine. (Note:The
'inherited' has nothing to do whith 'inheritation' of an object.!!)
procedure PrintFile;inherit ProcessTextFile('me.cfg');
vlStr : string;
vlLineCnt := 0;
while not eof do begin
vlLineCnt := vlLineCnt + 1;
inherited of main;
writeln('Lines : ',vlLineCnt);
The above routine means :
* Create a new routine wich is the same processtextfile but the routine
DoSomeThing is replace by a new one.
* The "('me.cfg')" is the parameter mapping. THis doesn't mean that
the parent is called with some parameter. The parameter 'ParFileName' in
ProcessTextFile is declared virtual. WHen a new Routine is derived from
ProcessTextFile this parameter can be removed from from the parameter list,
and initilized with a constand. (Parameter mapping is more complicated,
for more information see web site www.elaya.org)
In the above example it is not necesary to open,close the file and check
for error (Partly). It is also possible to cluster ReadLine,vlLineCnt, wich
makes it use easier. etc etc
Dynamic routines and even normal routines represents processen.
A process is 'A series of actions or operations used in making or
manufacturing or achieving something'.
The advantage of a dynamic routine is the same as object/classes, but
not regarding object but processes.
This is nicely showen when dynamic routines are used as a method in a class.
If we have a class TList, with childeren TNumberList and TStringList.
All these classes can contain the following methods :
Dynamic routine/Class form a 2 dimension relations ship.
One dimension is 'class':
TList.LargestValue, TNumberList.FindLargestValue and TStringList.FindLargestValue
(Same for other mehods)
And the other dimension is 'dynamic routine'
FindLargestValue, ValidateValue and PrintValue.is where dynamic routine is used.
The reason why this is the same for both : Similarities (inherit), differences
The usage of dynamic routine in 'OOP' is different as in procedural programming.
When thinking of 'but this can also be done with classes' remember that
you can choose of :Procedural, Procedural+Dynamic routine,OOP andOOP+Dynamic
routine. Beside that look at the following comparision.
Some comparision between dynamic routines and classes:
* Dynamic routine represnts processes and object/classes objects
* Dynamic routines don't need much RTL support and no dynamic memmory.
* From the outside a dynamic routine looks exactly the same as a normal routine.
* A dynamic routine can change its parameter
* Dynamic routine don't need to be Created and destroyd .
This text only is a introduction to dynamic routines. It took me a wile to
understand the advantages and differences between using and combining classes
and dynamic routines.(Warning the 'elaya' compiler doesn't contain OOP!! usage
of dynamic routines in classes are still theorie)
More information : www.elaya.org.
Return to the
Search the comp.compilers archives again.