From marcov at stack.nl Fri Feb 17 18:55:56 2017 From: marcov at stack.nl (Marco van de Voort) Date: Fri, 17 Feb 2017 18:55:56 +0100 (CET) Subject: [fpc-announce] FPC 3.0.2 released! Message-ID: <20170217175556.480B45082E@toad.stack.nl> Hello, Finally, FPC 3.0.2 has landed. FPC 3.0.2 is an update to 3.0.0 that contains some compiler bugfixes and library progress since 3.0.0 Building is still in progress and some formats (deb) and other minor targets might not be available yet. Changes that may break backwards compatibility are documented at: http://wiki.freepascal.org/User_Changes_3.0.2 Due to issues with mirroring, please use sourceforge as much as possible, http://sourceforge.net/projects/freepascal/files/ or the main (Hungarian) FTP server at ftp://www.hu.freepascal.org/pub/fpc/dist/3.0.2 Enjoy! The FreePascal team Free Pascal Compiler Version 3.0.2 ****************************************************************************** What's New in 3.0.2 ****************************************************************************** Free Pascal 3.0.2 is a point release of the 3.0.x fixes branch. Please also see http://wiki.freepascal.org/User_Changes_3.0.2 for a list of changes that may affect the behaviour of previously working code, and how to cope with these changes. Some highlights are: Rtl: * TRect, TPoint and similar types are now type compatible between Types and Windows unit, and are now advanced records. Packages: * googleapi and fcl-pdf packages. * fcl-db and web packages synchronized * unicode tables updated. See http://bugs.freepascal.org/changelog_page.php for the list of reported bugs which have been fixed in this release. From hnb.code at gmail.com Tue Feb 28 12:20:05 2017 From: hnb.code at gmail.com (Maciej Izak) Date: Tue, 28 Feb 2017 12:20:05 +0100 Subject: [fpc-announce] Feature announcement: Management Operators Message-ID: Hi, I'm pleased to finally announce (again but now officially ;) ) the additional record operators: Initialize, Finalize, AddRef and Copy. Available in latest FPC trunk (r35485): 1. operator Initialize - is called after memory allocation for record (called *after* FPC internal call recordrtti(data,typeinfo, at int_initialize);) 2. operator Finalize - is called when record goes out of scope (called *before* FPC internal call recordrtti(data,typeinfo, at int_finalize);) 3. operator AddRef - is called after the contents of a record has been duplicated by copying the contents byte by byte (called *after* FPC internal call recordrtti(data,typeinfo, at int_addref); ) 4. operator Copy - Copy operator (if exists) is called *instead of* default copy behavior. Operator is responsible for copying everything that's needed from the source to the target. AddRef and Copy might be at beginning a little hard for understanding but we have good explanation provided by Thorsten Engler in topic "Management operators : Copy and Clone confusion..." : === quote begin === the reason for both to exist is that there are cases (e.g. passing an interface parameter) where the callee is responsible for any lifetime management implications (and the caller might not even be implemented using fpc). The caller just passes the interface pointer on the stack (or in a register), which, while it creates a copy of the bytes, does not actually invoke the copy operator. In cases where reference counting is required (parameter not marked as const), the callee may decide to simply use the value that was passed on the stack as the backing for the parameter, so it calls AddRef on that, without performing another copy. Given this context, I find the terms AddRef and Copy to be perfectly adequate, even when applied to types that aren't strictly speaking performing reference counting; e.g. IIRC, AddRef for a BSTR (ole string type for windows which does NOT have a reference count) actually involves making a copy of the string contents and replacing the BSTR pointer. AddRef here means "this is now an *additional* *reference* to whatever these bytes might refer to". === quote end === my 2 cents for above: AddRef exist to speed up things. New set of operators is unique and is called "management operators". That is because: A. each of record (even non managed or even empty) with management operator becomes managed type. B. is possible to implement new custom types (also thanks to other operators) with own management of memory (new string types, fast TValue implementations without hacks on RTL etc.). C. "management operators" have no result. D. For management operators is generated simple VMT (thanks to this is possible to work with management operators together with all RTL functions like InitializeArray/FinalizeArray). === example declaration begin === PFoo = ^TFoo; TFoo = record private class operator Initialize(var a: TFoo); class operator Finalize(var a: TFoo); class operator AddRef(var a: TFoo); class operator Copy(constref aSrc: TFoo; var aDst: TFoo); end; === example declaration end === Management Operators feature can be used for many things: * support for value types * nullable types * some custom ARC variations * speed up existing types * very fast RTTI.TValue implementation * as replacement for manually called Init/Done record methods like in mORMot for many types (for example SynCommons.TSynLocker). * auto init/finit for pointers/classes/simple types or whatever we have in Pascal It works correctly in all possible ways with RTL: * New (Initialize) * Dispose (Finalize) * Initialize (Initialize) * Finalize (Finalize) * InitializeArray (Initialize) * FinalizeArray (Finalize) * SetLength (Initialize/Finalize) * Copy (AddRef) * RTTI.IsManaged Managements operators are often called implicitly in many cases. Few examples: * global variables (Initialize/Finalize) * local variables (Initialize/Finalize) * for fields inside: records, objects, classes (Initialize/Finalize) * variable assignment (Copy) * for parameters for routines (AddRef/Finalize/none - depends on modifiers like var/constref/cons) Own experiments recommended! :) Complex example and test: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/tes t/tmoperator8.pp?view=co&content-type=text%2Fplain Note: Lazarus (trunk version) has support for all new operators syntax (thanks for Mattias Gaertner). Future directions and opened doors (where management operators can be used but not directly): + "default" field for better handling smart pointers / nullable types (maybe will be introduced new type called proxy record for handling "default" modifier) (eg. https://github.com/maciej-izak/PascalSmartPointers compilable with NewPascal) + New VMT entry "vmtManagedInit" for "Initialize operator" for record fields inside classes (optimization) + Base for Nullable types syntax sugar + Probably base in some way for ARC classes (DELPHINEXTGEN compiler mode) + More Oxygene compatibility + Aspects Note for myself: document the feature on the wiki in New Features Trunk and the changes to the Rtti in User Changes Trunk :) -- Best regards, Maciej Izak -------------- next part -------------- An HTML attachment was scrubbed... URL: