Re: [BLACKBOX] Polymorphism

From: [at]} <Aubrey.McIntosh{>
Date: Thu, 20 Nov 2008 23:30:24 -0600

----boundary-LibPST-iamunique-915461020_-_-
Content-type: text/plain

Hi Doug, Alexander,

Thanks for your comments.

I am working with Alexander's post, building compilable modules and
tinkering with it. Prior to reading his email, I was working with the
interface below. This is a tiny modification of the code that I
dropped into pastebin and announced a day or so ago. The ForEach name
change seems ok with me. I had also thought of "Enumerate" because I
thought I saw it used in several specimens of Oberonish code.

I am taking the Alm01Gather project that I released in Component
Pascal last March and trying to re-factor it into a List module and
the other resulting code. This is for personal development --- I need
more experience with the NEW, ABSTRACT, EXTENSIBLE and other language
additions. Some re-factoring has been accomplished, and I am at the
point where a couple of the list traversals are recursive, and
terminate when a condition is satisfied.

This is an interesting thing to do. It may reveal improvements or
lack of regularity in the code. It is also interesting to try to
comprehend code that is more than a decade old.

In the Alm01Gather project I have records named Module and Import.
The problem that I am looking at is that there are different actions
for the record Import. At various times I want to walk the lists and
do different things, such as find a source file and scan it, recurse
to an import that does not have not yet compiled modules, list the
file name into a text.



DEFINITION Alm01List_temp;

        CONST
                opEq = 1;
                opGt = 2;
                opLt = 0;

        TYPE
                List = POINTER TO ABSTRACT RECORD
                        (this: List) Compare (other: List; op: SET): BOOLEAN, NEW, ABSTRACT;
                        (this: List) Do (VAR params: ANYREC), NEW, EMPTY;
                        (root: List) DoEach (VAR params: ANYREC), NEW;
                        (root: List) Initialize, NEW, EXTENSIBLE;
                        (root: List) Insert (nova: List), NEW, EXTENSIBLE;
                        (root: List) Insert_Patch (nova: List), NEW, EXTENSIBLE;
                        (this: List) New (params: ANYPTR): List, NEW, ABSTRACT;
                        (this: List) Next (): List, NEW, EXTENSIBLE;
                        (rider: List) OpDropInsert (nova: List), NEW, EXTENSIBLE;
                        (rider: List) OpInsert (nova: List), NEW, EXTENSIBLE;
                        (root: List) Remove (obsolete: List), NEW
                END;

END Alm01List_temp.



On Thu, Nov 20, 2008 at 11:03 PM, Douglas G. Danforth
<danforth{([at]})nowhere.xy
> Aubrey,
>
> How about having a list of ABSTRACT objects with the ABSTRACT class having
> an
> ABSTRACT method Do? Then each different extension of the class can
> implement its
> Do method anyway it wants. Hence the list can be heterogeneous.
>
> -Doug
>
>
> Aubrey.McIntosh{([at]})nowhere.xy
>>
>> In writing my List module, I have a method DoEach that walks the list,
>> and applies method Do to each element.
>>
>> (this: List) Do (VAR params: ANYREC), NEW, EMPTY;
>> (root: List) DoEach (VAR params: ANYREC), NEW;
>>
>> In moving some existing software to the new library module, it turns
>> out that I wish to apply a few different procedures to the list. In
>> trying to avoid procedure variables, I find I am drawing a blank.
>> Making several lateral extensions to the base record may be an
>> approach, particularly if there is a pointer to a record with that
>> particular implementation as one of the fields in params. I will
>> alternate between envisioning some structure to do this and Goggling
>> for the next while. A brief search of "Component Pascal Polymorphism"
>> seems more or less on target and enough reading to fill a night.
>>
>> I thought I saw some message about this under the general heading of
>> polymorphism on this list some years ago. If anyone remembers this,
>> or can point to a file either in the distribution or online I'd focus
>> my thoughts there fairly early on.
>>
>>
>>

>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
> LISTSERV{([at]})nowhere.xy
>



-- 
-- 
Aubrey McIntosh, Ph.D.
1502 Devon Circle
Austin TX 78723-1814
http://home.grandecom.net/~amcintosh/aubrey/Search/
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-915461020_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ld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2lyY2xl
XHBhcg0KQXVzdGluIFRYIDc4NzIzLTE4MTRccGFyDQpodHRwOi8vaG9tZS5ncmFuZGVjb20ubmV0
L35hbWNpbnRvc2gvYXVicmV5L1NlYXJjaC9ccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8g
dW5zdWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIg
dG8gTElTVFNFUlZATElTVFMuT319ACunv1mxKpIHkEbDIg==
----boundary-LibPST-iamunique-915461020_-_---
Received on Fri Nov 21 2008 - 06:30:24 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:51 UTC