[fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX
Hi all, Anyone having an idea when Lazarus is to be released with FPC 2.3.1 for i386 Mac OSX? Thanks, Normann ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
On Tue, 5 Feb 2008, Tiziano De Togni wrote: > > From the Delphi (7) help and in the borland newgroups I read that the old TP > style object type is considered to disappear, and actually only kept for code > compatibility. > > I see here that some developers still use the type object because of some > advantages against the Class type (static allocation). > > Can someone explain better these advantages? The advantage is mainly that you can have objects on the stack. > > My other question is: > Will Free Pascal still support the type object in the future or it is > considered to disappear in the same way as it is expected in Delphi? It will not disappear, but all new development is done using classes: the old objects will not evolve. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
> My other question is: > Will Free Pascal still support the type object in the future or it is > considered to disappear in the same way as it is expected in Delphi? It won't disappear in FPC, even the compiler itself uses it at certain places. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
[fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
From the Delphi (7) help and in the borland newgroups I read that the old TP style object type is considered to disappear, and actually only kept for code compatibility. I see here that some developers still use the type object because of some advantages against the Class type (static allocation). Can someone explain better these advantages? My other question is: Will Free Pascal still support the type object in the future or it is considered to disappear in the same way as it is expected in Delphi? tia -- tiziano __ http://digilander.libero.it/tizzziano/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
On Tuesday 05 February 2008 12:02, Tiziano De Togni wrote: > Michael Van Canneyt ha scritto: > > > > The advantage is mainly that you can have objects on the stack. > > sorry, but don't understand exactly what this means exactly. The main difference is here: -- 8< -- procedure Uses_Objects; var My_Object : tMyObject; My_Class : tMyClass; begin My_Object.Init; My_Class := tMyClass.Create; end {Uses_Objects}; -- 8< -- The memory allocation for the class can fail due to resource exhaustion and also is infinitely slower than the allocation for the object, which is there as soon as the procedure has been entered. On assembly level, it is only a different constant that the stack pointer is moved to make space for the local variables. Referencing an instance being on the stack may also be a bit faster than referencing an instance being on the heap, because there's one level of dereference less, and it may be even more cache-friendly, because the stack is more likely to be in the cache already than a (newly) allocated memory block. Meaning: Memory space and execution speed is more or less known beforehand and potential memory fragmentation problems are avoided. Oh, and one thing more: No access violations when referencing an invalid (not yet initialized) instance. ;) Vinzent. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX
Bent Normann Olsen schreef: Hi all, Anyone having an idea when Lazarus is to be released with FPC 2.3.1 for i386 Mac OSX? There won't be Lazarus releases with FPC 2.3.1, because FPC 2.3.1 is not a release, but a development snapshot. FPC 2.3.1 will become FPC 2.4.0, when it will be released. The next Lazarus release after the FPC 2.4.0 release, will be released for FPC 2.4.0. Before FPC 2.4.0 is released, I expect at least a FPC 2.2.2 and possibly a FPC 2.2.4 (and 2.2.6). So I personally don't expect FPC 2.4.0 in 2008 and chances are not too high for 2009 either. Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Op Tue, 5 Feb 2008, schreef Tiziano De Togni: Michael Van Canneyt ha scritto: On Tue, 5 Feb 2008, Tiziano De Togni wrote: From the Delphi (7) help and in the borland newgroups I read that the old TP style object type is considered to disappear, and actually only kept for code compatibility. I see here that some developers still use the type object because of some advantages against the Class type (static allocation). Can someone explain better these advantages? The advantage is mainly that you can have objects on the stack. sorry, but don't understand exactly what this means exactly. I understand that if I write a procedure of this kind: procedure processmyobject(myobject: tmyobject); procedure processmyobject(myclass: tmyclass); I have myobject on the stack, instead myclass is passed by reference, but don't see the advantage... Stack allocation is much faster than heap allocation, and automatic. Take a look at the matrix unit; you can return an object from a function without worrying about memory leaks, so they are very usefull in function results and operator overloading. Further, objects allow you control the binary layout (the binary layout is just like a record), which means you can fit existing data structures (like those used in files) with methods. Some time ago we had a discussion about this list about mapping the GTK Gobject model to Pascal objects, succesfull experiments were done. Daniël___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Michael Van Canneyt ha scritto: On Tue, 5 Feb 2008, Tiziano De Togni wrote: From the Delphi (7) help and in the borland newgroups I read that the old TP style object type is considered to disappear, and actually only kept for code compatibility. I see here that some developers still use the type object because of some advantages against the Class type (static allocation). Can someone explain better these advantages? The advantage is mainly that you can have objects on the stack. sorry, but don't understand exactly what this means exactly. I understand that if I write a procedure of this kind: procedure processmyobject(myobject: tmyobject); procedure processmyobject(myclass: tmyclass); I have myobject on the stack, instead myclass is passed by reference, but don't see the advantage... -- tiziano __ http://digilander.libero.it/tizzziano/ ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE: [fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX
Thanks for the reply, I was especially interested in the 2.3.1 fix in the sizes for enumerated types. Small enumerated types in FPC 2.2.0 has the size of 4 bytes, and 1 byte in Delphi. Sizes of small enumerated types in FPC 2.3.1 is 1 byte after the fix. I understand, that "set of" types has the size of 4 bytes or 32 bytes, and probably will be this way for the future releases of FPC. This is to keep compatibility for written records and record sizes in files in mind. A workaround is of course to use byte and type casting instead. Is there any chances this fix in 2.3.1 will be available in 2.2.x versions of FPC? Normann -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vincent Snijders Sent: 5. februar 2008 12:16 To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX Bent Normann Olsen schreef: > Hi all, > > Anyone having an idea when Lazarus is to be released with FPC 2.3.1 for i386 > Mac OSX? There won't be Lazarus releases with FPC 2.3.1, because FPC 2.3.1 is not a release, but a development snapshot. FPC 2.3.1 will become FPC 2.4.0, when it will be released. The next Lazarus release after the FPC 2.4.0 release, will be released for FPC 2.4.0. Before FPC 2.4.0 is released, I expect at least a FPC 2.2.2 and possibly a FPC 2.2.4 (and 2.2.6). So I personally don't expect FPC 2.4.0 in 2008 and chances are not too high for 2009 either. Vincent ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Yes, objects (by specification) are defined to have the same binary layout as records. Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Objects can have virtual methods, constructors, destructors. The new Delphi feature cannot. Daniël___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Daniël Mantione wrote: [..] Stack allocation is much faster than heap allocation, and automatic. Take a look at the matrix unit; you can return an object from a function without worrying about memory leaks, so they are very usefull in function results and operator overloading. Further, objects allow you control the binary layout (the binary layout is just like a record), which means you can fit existing data structures (like those used in files) with methods. Some time ago we had a discussion about this list about mapping the GTK Gobject model to Pascal objects, succesfull experiments were done. In a external c library, i have a structure like TMyType = record x: Integer; y: Integer; end; PMyType = ^TMyType; and a function that expects a pointer to that record function DoIt(MyVar: PMyType); can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Luiz ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX
On 05 Feb 2008, at 13:24, Bent Normann Olsen wrote: Thanks for the reply, I was especially interested in the 2.3.1 fix in the sizes for enumerated types. Small enumerated types in FPC 2.2.0 has the size of 4 bytes, and 1 byte in Delphi. Sizes of small enumerated types in FPC 2.3.1 is 1 byte after the fix. You can make them 1 byte in FPC 2.2.0 by using {$packenum 1}. It's possible that {$packenum 1} has become the default in Delphi mode in 2.3.1, I don't know. I understand, that "set of" types has the size of 4 bytes or 32 bytes, and probably will be this way for the future releases of FPC. Delphi-compatible set packing is already available FPC 2.2.1. Storing sets in a binary file is a very bad idea though, because they are opaque types and you cannot rely in any way on their internal format. They're also incompatible between little and big endian systems. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
RE: [fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX
Jonas, Thanks for the reply. I tested this on FPC 2.2.0 for i386 Mac and it worked just as you described. This is only a workaround for files already stored from a current version of an application, and future versions will not behave this way ;-) Thanks again, Normann -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jonas Maebe Sent: 5. februar 2008 13:36 To: FPC-Pascal users discussions Subject: Re: [fpc-pascal] Lazarus with FPC 2.3.1 i386 Mac OSX On 05 Feb 2008, at 13:24, Bent Normann Olsen wrote: > Thanks for the reply, > > I was especially interested in the 2.3.1 fix in the sizes for > enumerated > types. Small enumerated types in FPC 2.2.0 has the size of 4 bytes, > and 1 > byte in Delphi. Sizes of small enumerated types in FPC 2.3.1 is 1 > byte after > the fix. You can make them 1 byte in FPC 2.2.0 by using {$packenum 1}. It's possible that {$packenum 1} has become the default in Delphi mode in 2.3.1, I don't know. > I understand, that "set of" types has the size of 4 bytes or 32 > bytes, and probably will be this way for the future releases of FPC. Delphi-compatible set packing is already available FPC 2.2.1. Storing sets in a binary file is a very bad idea though, because they are opaque types and you cannot rely in any way on their internal format. They're also incompatible between little and big endian systems. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
> Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: > > Moreover, whats the difference between objects and records with methods > > (the > > new Delphi feature)? > > Objects can have virtual methods, constructors, destructors. The new > Delphi feature cannot. The records-with-methods feature originates from .NET, but some cases were made that they were also added to restrict the search for methods for duck-type style other new delphi features like for..in, and similar future expansion. Probably when these features are more closely regarded, additional reasons/behaviour will pop up. A very rough summary of the msgs and (IRC-)discussions about the newer delphi features can be found here: http://www.stack.nl/~marcov/delphilater.txt ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Yes, objects (by specification) are defined to have the same binary layout as records. Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Objects can have virtual methods, constructors, destructors. The new Delphi feature cannot. however with virtuals or constructors/destructors, the memory layout is not 100% the same as a record. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Vinzent Hoefler wrote: On Tuesday 05 February 2008 12:02, Tiziano De Togni wrote: Michael Van Canneyt ha scritto: The advantage is mainly that you can have objects on the stack. sorry, but don't understand exactly what this means exactly. The main difference is here: -- 8< -- procedure Uses_Objects; var My_Object : tMyObject; My_Class : tMyClass; begin My_Object.Init; My_Class := tMyClass.Create; end {Uses_Objects}; -- 8< -- The memory allocation for the class can fail due to resource exhaustion and also is infinitely slower than the allocation for the object, which is there as soon as the procedure has been entered. On assembly level, it is only a different constant that the stack pointer is moved to make space for the local variables. Referencing an instance being on the stack may also be a bit faster than referencing an instance being on the heap, because there's one level of dereference less, and it may be even more cache-friendly, because the stack is more likely to be in the cache already than a (newly) allocated memory block. Meaning: Memory space and execution speed is more or less known beforehand and potential memory fragmentation problems are avoided. Oh, and one thing more: No access violations when referencing an invalid (not yet initialized) instance. ;) Another difference, the memory of a class is zeroed on creation. This means that all membervars have the value of 0/nil, where for an object only automated member types are initialized. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Op Tue, 5 Feb 2008, schreef Marc Weustink: Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Yes, objects (by specification) are defined to have the same binary layout as records. Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Objects can have virtual methods, constructors, destructors. The new Delphi feature cannot. however with virtuals or constructors/destructors, the memory layout is not 100% the same as a record. A constructor doesn't add a vmtlink. A virtual method does, and a destructor too because they are virtual. It is never a problem in practise, because you can declare the virtual method in a descendent, i.e.: type Tbinary_compatible_obj=object a,b,c,d,e,f:byte; constructor init; end; Tbinary_compatible_obj_with_vmt=object(Tbinary_compatible_record) constructur init; procedure virtualmethod;virtual; desctructor done;virtual; end; In the above example, you can perfectly pass a Tbinary_compatible_obj_with_vmt instance to any C library expecting a Tbinary_compatible_obj, because the vmtlink is located after the fields and therefore does not interfere with the binary structure. Daniël___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Turbo Pascal and Object Pascal ways of OOP
Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Marc Weustink: Daniël Mantione wrote: Op Tue, 5 Feb 2008, schreef Luiz Americo Pereira Camara: can i safely use the below object instead of the record and pass directly to the c function? TMyObj = object x: Integer; y: Integer; Method1; Method2; end; PMyObj = ^TMyObj; Yes, objects (by specification) are defined to have the same binary layout as records. Moreover, whats the difference between objects and records with methods (the new Delphi feature)? Objects can have virtual methods, constructors, destructors. The new Delphi feature cannot. however with virtuals or constructors/destructors, the memory layout is not 100% the same as a record. A constructor doesn't add a vmtlink. A virtual method does, and a destructor too because they are virtual. It is never a problem in practise, because you can declare the virtual method in a descendent, i.e.: type Tbinary_compatible_obj=object a,b,c,d,e,f:byte; constructor init; end; Tbinary_compatible_obj_with_vmt=object(Tbinary_compatible_record) constructur init; procedure virtualmethod;virtual; desctructor done;virtual; end; In the above example, you can perfectly pass a Tbinary_compatible_obj_with_vmt instance to any C library expecting a Tbinary_compatible_obj, because the vmtlink is located after the fields and therefore does not interfere with the binary structure. it might be a compiler bug, but when I tried to zeromem a object having a constructor it resulted in an IE. Without a constructor not. That way I came to a conlusion that an object+constructor is not 100% the same as a simple record. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal