[comp.lang.pascal] OOP features in Turbo Pascal 5.5

grs@wucs1.wustl.edu (Guillermo Ricardo Simari) (05/17/89)

Any comments about the OOP features in Turbo Pascal 5.5
and Quick Pascal of Microsoft?


Guillermo R. Simari                    Washington University
(grs@wucs1.wustl.edu)                  Department of Computer Science
                                       St. Louis, MO, 63130-4899, U.S.A. 

milne@ics.uci.edu (Alastair Milne) (05/20/89)

grs@wucs1.wustl.edu (Guillermo Ricardo Simari) writes
>Any comments about the OOP features in Turbo Pascal 5.5
>and Quick Pascal of Microsoft?
  
     Turbo Pascal 5.5?  Last one I knew of was 5.0 .  Is this a simple typo,
     or have a I missed an announcement from Borland?  

     I don't know of "Quick Pascal".  The only Pascal I know of from Microsoft
     is, as you would expect, MS Pascal.

     As in UCSD Pascal, Turbo 4, Mac Pascal, Modula-2, etc. the unit construct
     can be used quite effectively for creating a certain degree of object
     orientation -- though I would probably continue to prefer the term
     "abstract data types", since the unit feature doesn't directly support 
     such features as message passing -- if it's going to happen, it must be
     of the programmer's creation.  Nor do you have such properties as
     inheritance: rather, if you export a new type, you can also export
     routines which apply exclusively to objects that the client declares to
     be of that type.

     So how effective units are for object-orientation really depends rather 
     heavily on how cleanly the programmer defines the interface of the unit 
     -- types to be exported, operations to be exported for them -- and 
     it can be as easy to export an inconsistent, unsecure, half-supported 
     mess as to export a solid, seamless, fully-functional new data type.  
     The syntax doesn't provide quite the guidance (or power) of, say, 
     Ada packages.  

     Units, of course, have quite a number of other advantages, especially if
     you know how to use them well.  The list could run to a fair-sized essay,
     which I won't try to do here.


     Alastair Milne

rogerson@PEDEV.Columbia.NCR.COM (Dale Rogerson) (05/26/89)

In article <15150@paris.ics.uci.edu> Alastair Milne <milne@ics.uci.edu> writes:
>grs@wucs1.wustl.edu (Guillermo Ricardo Simari) writes
>>Any comments about the OOP features in Turbo Pascal 5.5
>>and Quick Pascal of Microsoft?
>  
>     Turbo Pascal 5.5?  Last one I knew of was 5.0 .  Is this a simple typo,
>     or have a I missed an announcement from Borland?  
Again? Didn't I just upgrade to version 5.0? :-) I had to wait years for version4.0 and now every other month they come out with a new version.  I new there
was a catch to their low prices! (-: :-)
>
>     I don't know of "Quick Pascal".  The only Pascal I know of from Microsoft
>     is, as you would expect, MS Pascal.
It is listed in the Programmer's Connection Buyer's guide ($99 list).
>
>     As in UCSD Pascal, Turbo 4, Mac Pascal, Modula-2, etc. the unit construct
>     can be used quite effectively for creating a certain degree of object
>     orientation -- though I would probably continue to prefer the term
>     "abstract data types", 
>     Alastair Milne

The main problem with the Unit construct in the Turbo 4 is the lack of hidden
data, and generics.  These two features, found in Modula 2, allow the creation
of better abstact data types.  In TP if you want someone to use a data type
created in your unit (i.e. to pass it to you etc.) then this data type must
be fully discribe in the interface section of the unit.  This has the potential
for abuse.  If someone knows the implementation of you data type, the may start
coding in a way that will abuse the OOPs design.

Generics are even better, they make programming funner :-).  With generics
you can create link lists, stack, and other such structures without having to
worry about what kind of data is in the linked list or the stack.  This is
a really nice feature.

-----Dale
	Rogerson-----

milne@ics.uci.edu (Alastair Milne) (05/26/89)

rogerson@PEDEV.Columbia.NCR.COM (Dale Rogerson) writes
>>     As in [various Pascal's, modula-2] the unit construct
>>     ... object >>     orientation -- though I would probably continue 
>> to prefer the term "abstract data types", 
>>     Alastair Milne
>The main problem with the Unit construct in the Turbo 4 is the lack of hidden
>data, and generics.  These two features, found in Modula 2, allow the creation
>of better abstact data types.  

    You are, of course, correct about the missing abilities in units.  This is
    probably because Turbo borrowed units, either directly or indirectly, from 
    UCSD Pascal, which installed them almost 10 years ago, and none of their
    inheritors (that is to say, none of the derivative Pascal dialects of
    which I'm aware) has looked at any serious extension of them.  In fact,
    they're stilling trying to do as much as UCSD units did.  So the
    limitations that were (and are) in UCSD units are to be expected in
    MicroSoft and Borland units.

    However, unless Wirth has recently updated Modula-2, it does not have 
    generics, and its concealment of data construction is half accidental:
    when you declare a type as a POINTER TO something else, the something else
    doesn't have to be listed in the description module (forgot the right
    name, sorry); however, if some external user takes a stab at a component 
    -- or even correctly names it by accident -- Modula-2 syntax makes it 
    available and manipulable.

    At the risk of being obvious, are you perhaps thinking of Ada, which has
    the features you name, and addresses explicitly the problem you mention?

>In TP if you want someone to use a data type
>... then [it] type must be fully discribe in the interface ...  This has 
> the potential for abuse.  If someone knows the implementation ...
>, the may start coding in a way that will abuse the OOPs design.

    Very true.  On our project, we've lived with this for years: our major
    screen support and general factotum unit is obliged to export some large
    and detailed types whose details we don't actually want any program to 
    know -- if they start depending on those details, we're in a tough
    situation come the next round of support upgrades.  But the best we can do
    is say in our manuals *HANDS OFF*, in the most convincing terms possible.

    BTW, that phrase "general factotum" may sound as if we've chucked the 
    kitchen sink into a single unit, and I'm afraid in a way we have.  This
    was done because at the time the operating system only allowed 7 units
    for one program, and we were pushing it, so things went together into
    the same unit which really should have been kept separate.  Having lived
    with the consequences for a number of years now has made me an ardent
    supporter of true modularity.

>Generics are even better, they make programming funner :-).  With generics
>you can create link lists, stack, and other such structures without having to
>worry about what kind of data is in the linked list or the stack. 

    "Funner?"  Yes, I think they do.  (Though why Ada makes this the only way
    of passing procedural parameters has never been clear to me.)

    There is no question that Ada provides superior data abstraction
    capabilities to any Pascal that I know of, which implies better service to
    your client modules, and better reliability.  What it costs you, though, 
    is something else again.  There may be some argument that Modula-2's
    half-hidden types and much reduced size are perhaps preferable to
    Ada's powerful export capacities but very considerable size.

    Boy is this off the topic.

    My final thought: if you know how to implement object-handling, units
    (whether UCSD, TP4, TP5) should provide a good platform for building it,
    provided you're prepared to handle the lack of privacy and the potential
    for abuse by users' being able to manipulate features that are intended
    for the unit's use alone.  On the other hand, why not wait for Turbo 5.5
    and see what having built-in object orientation can do for you?  (Assuming
    of course that other aspects of the new version are acceptable too).


    Alastair Milne