wsinrb@eutrc3.urc.tue.nl (r.bieling) (07/13/89)
Does any-one have any experience with turbo pascal 5.5 yet? I'm curious whether it is worth the upgrade or not. So far I didn't find too much about it in any magazine, any reviews available? Beside introduction of object oriented mechanisms, are there any more changes, new calls, or bug repairs? By the way, does any-one know which other machines will or do run turbo pascal, and how compatibility is guarantied if so? Thanks in advance. Rob Bieling Eindhoven the Netherlands
rogerson@PEDEV.Columbia.NCR.COM (Dale Rogerson) (07/14/89)
In article <799@eutrc3.urc.tue.nl> wsinrb@eutrc3.urc.tue.nl (r.bieling) writes: > >Does any-one have any experience with turbo pascal 5.5 yet? I just got it Weds, so I am just starting to play with it. >I'm curious whether it is worth the upgrade or not. So far I got it in order to play with the OOPS features which are derived from C++ and Apple's Object Pascal. For playing with OOPs it is probably worth the upgrade money. >I didn't find too much about it in any magazine, any reviews >available? I believe that Byte magazine, The Programmer's Journal, and Computer Language (maybe even Dr. Dobb's) all have articles on the new release. However, the ones I read only mentioned the new OOPs features. >Beside introduction of object oriented mechanisms, >are there any more changes, new calls, or bug repairs? Bugs Fixes? Turbo Products do not have any bugs to fix :-). This is at least the mentality of most software houses. I am sure they fixed some of the previous bugs. I do not know what those bugs were, and they are not about to tell me. Other changes include: - The case statement selector can now be any byte-sized or word-sized ordinal type such as type Word. - Overlays have been greatly improved with many additional procedures and functions. I have not used overlays since the old days so I do not really know how this differs from 5.0. - An online tutorial to introduce the programming environment. (This thing is a BIG joke. It is basically a bunch of screens saved in a file. and the tour program spits them back at you. It pretends that you are running the environment but you are not. Best line - "The program has already compiled and run." Yea, right. >By the way, does any-one know which other machines will or do >run turbo pascal, and how compatibility is guarantied if so? It is suppose to run on any almost MSDOS clone. That is, the command line version of the compiler should run on any computer that runs MSDOS. Anyone also playing with this? >Thanks in advance. Bitte, Bitte. -----Dale Rogerson-----
rogerb@iscuvc.iscs.com (Roger Bailey) (07/15/89)
In article <799@eutrc3.urc.tue.nl> wsinrb@eutrc3.urc.tue.nl (r.bieling) writes: > >Does any-one have any experience with turbo pascal 5.5 yet? >I'm curious whether it is worth the upgrade or not. So far > > [text deleted] > >Rob Bieling >Eindhoven >the Netherlands I am also interested if it is worth the upgrade. Roger -- UUCP: rogerb@iscuva.ISCS.COM | ...uunet!iscuva!rogerb | "... I'm just making this up as I go." | Indiana Jones
snuzs@trsvax.UUCP (07/16/89)
>Beside introduction of object oriented mechanisms, >are there any more changes, new calls, or bug repairs? I don't have my upgrade yet (It's in the mail) but my friend has received his and one thing that has changed is the help file. Each key word now also contains complete sample code and any part of the help file can be pasted into your source. Just thought you might be interested. ****************************************************************************** Scott Parrish Domain: snuzs@trsvax.Tandy.COM Tandy Electronics UUCP: ...!texbell!letni!trsvax!snuzs Fort Worth, Texas or: ...!decvax!microsoft!trsvax!snuzs ****************************************************************************** DISCLAIMER: Since Tandy Corporation and Radio Shack won't be responsible for what I say, I guess I'll have to be. ******************************************************************************
wei@hpctdls.HP.COM (Bill Ives) (07/19/89)
I just received my upgrade package and have read the chapter on OOP. I will try not to reelaborate what previous posters have said. Basicly, there are four new keywords and a couple of new functions that are used to support OOP. The new keywords are: object constructor destructor virtual The new fuuntions are really just new forms of new dispose The new proc can now take the pointer as the first parameter and a constructor as a second parameter. i.e. new(myptr,Init(0)); Here "Init" is the arbitrary but suggested name (by Borland) of the constructor for object of which myptr points to. Dispose has a similar form but with the destructor as the second parameter: Dispose(myptr,Done); The new routine can also be called like malloc is in C --- myptr := new(myobjtype); The "object" keyword is used just like the RECORD keyword is but instead defines an object, which can contain methods (procs and funcs) : type myobj = object x : integer ; { all vars MUST come first } constructor Init( i: integer);{ "constructor" keyword used like "procedure" } destructor Done; { note keyword destructor is used like "procedure" } procedure mymethod( var i : integer ); end; All methods associated with an object must be defined in the following form: procedure myobj.mymethod( var i : integer ) begin x := i ; { note assignment to myobj's x field which is possible since this is a member method of myobj } end; This code might be called like: var mine:myobj ; begin mine.mymethod(1); end. The constructor and destructor methods must be called when the object contains virtual methods or unpredicable result may occur. Even if the object is statically allocated and is then assigned to another object the new object must be initialized to ensure that its VMT (virtual ?memory? table) is properly connected -- there are some big warnings about this in the manual. For example if the myobj object above did contain the virtual method: procedure myvirt( i:integer ) virtual ; { syntax may not be right here} the following code demonstrates what initialzation is required: var myptr : ^myobj ; mine : myobj ; begin new(myptr,Init(2)); { allocates and inits the dynamic var } mine := ^myptr ; { assign dynamic var to the static var } mine.Init(2) ; { initialize the static var } end; The manual describes this is great detail -- for now beware. Virtual methods are used to allow descendant objects to replace parents virtual methods with there own. The following code not only shows this but also shows how inheritance is done: type aa = object i : integer ; procedure virt1; virtual; procedure test; end; bb = object ( aa ) { bb inherits from object aa } j : integer ; procedure virt1; virtual; end; procedure aa.virt1 begin writeln('hello'); end; procedure aa.test begin virt1; end; procedure bb.virt1 begin writeln('world'); end; var a: aa; b : bb ; begin { initialize both a and b since they have virtuals in them } a.test; { this will print out 'hello' } b.test; { this will print out 'world' } end. Virtual methods allow a descendant to override ancestor methods. Object can also be assigned AS LONG AS THEY CAN FILL THE TARGET. Thus a:= b ; would work above since b contains everything that a does plus the variable j. b:=a ; would fail at compilie time since a cannot fill in b's j variable. This same type of logic works for type checking and parameter passing: For the procedure: procedure mine( i : aa ); the following calls are legal: mine(a); and mine(b); For anyone familiar with C++ here are some notes: constructors and destructors are NOT called automatically like C++ there is no such thing as operator overloading only single inheritance is support ( ala ATT C++ version 1.2 ) not multiple inheritance (ala C++ 2.0) the standard OOP features such as polymorhism and encapsulation are supported through object and virtual keywords. method overloading appears to be possible if the methods are static and have different number/type of parameters ( I haven't tried this ) since pascal does not normally support the returning of records from functions I suspect ( it was not documented ) that they cannot return objects. data hiding (i.e. private vs public) seems to be absent from the object definition itself but can be supported somewhat with the UNIT INTERFACE IMPLEMENTATION usage. There appears to be no way to really hide data or methods in an exported object. Hope this helps those of you who are curious about TP 5.5 -- I hope it was worth the price I paid -- I don't know yet. Bill Ives Hewlett-Packard CTD include <std-disclaimer> I do not represent Borland or speak for anyone but myself.
lsr@Apple.COM (Larry Rosenstein) (07/22/89)
In article <390004@hpctdls.HP.COM> wei@hpctdls.HP.COM (Bill Ives) writes: > The constructor and destructor methods must be called when the object > contains virtual methods or unpredicable result may occur. Even if the > object is statically allocated and is then assigned to another object This is pretty bad, in my opinion. If you are going to define the concept of constructors and destructors, you should also have them called automatically. This is one of the nice features of C++, and it is unfortunate that Borland didn't recognize it as a good feature. In C++ you can be sure that the internal state of an object is always consistent, because the constructor would have been called. > mine := ^myptr ; { assign dynamic var to the static var } > mine.Init(2) ; { initialize the static var } The fact that you have to call the constructor after an assignment is a very serious deficiency. It makes it more difficult to deal with objects than with other types. Presumably, you wanted to make a copy of the object in this case, so how do you know what to pass to the constructor? This is changing the meaning to assignment as applied to objects. (A question. What if you pass an object as a parameter. Does the called routine have to call its constructor?) Larry Rosenstein, Apple Computer, Inc. Object Specialist Internet: lsr@Apple.com UUCP: {nsc, sun}!apple!lsr AppleLink: Rosenstein1
dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (07/23/89)
In article <2971@internal.Apple.COM> lsr@Apple.COM (Larry Rosenstein) writes: >In article <390004@hpctdls.HP.COM> wei@hpctdls.HP.COM (Bill Ives) writes: > >> The constructor and destructor methods must be called when the object >> contains virtual methods or unpredicable result may occur. Even if >the >> object is statically allocated and is then assigned to another object > >This is pretty bad, in my opinion. If you are going to define the concept >of constructors and destructors, you should also have them called >automatically. This is one of the nice features of C++, and it is >unfortunate that Borland didn't recognize it as a good feature. In C++ >you can be sure that the internal state of an object is always consistent, >because the constructor would have been called. In TP 5.5, you're allowed multiple constructors in a single object, presumably to allow it to be initialized in different ways depending on the circumstances. You're also allowed to pass parameters to the constructor, and the different constructors don't need to take the same parameters. Both of these mean the constructor can't be called automatically. Isn't this a problem in C++? Duncan Murdoch
andru@rhialto.sgi.com (Andrew Myers) (07/25/89)
In article <317@maytag.waterloo.edu> dmurdoch@watstat.waterloo.edu (Duncan Murdoch) writes: > >In TP 5.5, you're allowed multiple constructors in a single object, presumably >to allow it to be initialized in different ways depending on the circumstances. >You're also allowed to pass parameters to the constructor, and the different >constructors don't need to take the same parameters. Both of these mean >the constructor can't be called automatically. > >Isn't this a problem in C++? > >Duncan Murdoch No, it isn't. You can't create an object in C++ without calling a constructor method. To pass arguments to the constructor which requires them, you specify them when you declare the object, e.g. IntegerArray foo(5); Where a constructor IntegerArray::IntegerArray(int length); exists. If a class has a superclass with different constructor argument requirements, this can be handled as well: RawData::RawData(long bytes); IntegerArray::IntegerArray(int length) : (long(length * sizeof(int))) { ... } Andrew