Re: [BLACKBOX] Variant Records vs. Component Pascal

From: [at]} <Chris>
Date: Fri, 1 Jan 2010 09:17:03 +1030

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

Welcome! I think you'll find many here with similar backgrounds and
interests. My language path started in the late 60's with assembler, ALGOL
and FORTRAN IV, followed by Pascal in the 70's, Modula-2 in the 80's and
Delphi and Oberon / CP in the 90's. C was also somewhere in there for about
10 years but I've mostly been able to suppress those unpleasant memories ;-)

I'm sure you will be able to do what you are trying to do but recall similar
difficulties with variant records vs. type extensions when first using
Oberon. One brilliant book that really helped me make the switch to the
Oberon style of programming is Hanspeter Mössenböck's "Object-Oriented
Programming in Oberon-2". While reading that I had that satisfying "now I
get it!" experience. Unfortunately it is not easy to get a copy these days.

As to your specific current task - I'm sure somebody else will show you how
to do it once they've all recovered from the New Year celebrations.
Otherwise I'll try and track down some helpful examples for you.

Wishing you and everybody else here a Happy and Peaceful New Year,

Chris Burrows
CFB Software
http://www.armaide.com

________________________________

        From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
Stephen R. Troy
        Sent: Friday, 1 January 2010 7:42 AM
        To: BLACKBOX{([at]})nowhere.xy
        Subject: [BLACKBOX] Variant Records vs. Component Pascal
        
        
                Hello List,
        This is my first post to this list. To help you reply, I started
programming digital computers, in machine language, in 1957. Since then I
have done scientific and engineering programming in FORTRAN, BASIC, Pascal,
and then Modula-2 for many years. I have only limited familiarity with C.
Now retired, recently I have moved to Oberon and now Component Pascal,
writing programs to support hobbies.

        I have a program I have been evolving for several years, which reads
in a database which is in a structured ASCII text file using a third-party
database schema. The program develops several index files, performs various
sorting and filtering operations on these indexes, and the uses the modified
indexes to write out reports using the same database schema. There are
three main types of records, and I was able to write very efficient sorting
and filtering procedures in Modula-2 by writing the records as variant
records of a basic type, then instantiating the records by pointers. My
indexes were linked lists of the pointers, both linear and binary trees, and
so I could find, sort, and filter each of the three types of records using
the same very efficient code, because I manipulated only the pointers'
"next-record" pointer in the linked lists, not moving any records in memory.


        But I apparently I can't use this method in Component Pascal because
variant records are not allowed. I tried defining a basic record as an
ABSTRACT type, then defining each of my three record types as extensions.
However, I can't instantiate a record as a NEW(pointer to basic type), and I
can't use a single sort routine with each of the three (pointer to extension
type) -- I need three separate routines, which is clumsy at best, and seems
contrary to the basic intent of Component Pascal. I tried defining the
basic record type as EXTENSIBLE, but that made no difference. I found an
obscure section in the Component Pascal documentation that said that using a
RECORD [union] system flag, which allowed a "C-type" union data structure,
it was possible to simulate Pascal- and Modula-style variant records, but
the example in the documentation will not compile -- it gives an "invalid
system flag" error message on the [union] flag.

        Any suggestions would be welcome at this point.
        Thanks,
        Steve Troy
        
        ---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to
LISTSERV{([at]})nowhere.xy


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-681082525_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzc1xmY2hhcnNldDAgQXJpYWw7fQ0Ke1xmMVxmbW9kZXJuIENvdXJpZXIgTmV3O30NCntcZjJc
Zm5pbFxmY2hhcnNldDIgU3ltYm9sO30NCntcZjNcZm1vZGVyblxmY2hhcnNldDAgQ291cmllciBO
ZXc7fX0NCntcY29sb3J0YmxccmVkMFxncmVlbjBcYmx1ZTA7XHJlZDBcZ3JlZW4wXGJsdWUyNTU7
fQ0KXHVjMVxwYXJkXHBsYWluXGRlZnRhYjM2MCBcZjBcZnMyMCBXZWxjb21lISBJIHRoaW5rIHlv
dSdsbCBmaW5kIG1hbnkgaGVyZSB3aXRoIHNpbWlsYXIgYmFja2dyb3VuZHMgYW5kXHBhcg0KaW50
ZXJlc3RzLiBNeSBsYW5ndWFnZSBwYXRoIHN0YXJ0ZWQgaW4gdGhlIGxhdGUgNj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