Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-01

Free Pascal 2.4.0 released

35 messages · 15 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marco van de Voort

Happy New Year!

As a special present, We have placed a new major release of the Free Pascal Compiler, version 2.4.0 on our ftp-servers.

Changes that may break backwards compatibility are documented at: http://wiki.freepascal.org/User_Changes_2.4.0

Downloads are available at:

the main FTP server at

ftp://ftp.freepascal.org/pub/fpc/beta/2.4.0/

and

ftp://freepascal.stack.nl/pub/fpc/beta/2.4.0/

Enjoy!

The Free Pascal Compiler Team

Free Pascal Compiler

Version 2.4.0

****************************************************************************** What's New in 2.4.0
******************************************************************************

Free Pascal 2.4.0 contains many fixes and new features. While we did not manage to incorporate all planned additions, we believe this release offers a nice collection of new functionality and bug fixes.

Please also see http://wiki.freepascal.org/User_Changes_2.4.0 for a list of changes which may affect the behaviour of previously working code, and how to cope with these changes.

Some highlights are:

Platforms:
* New platform: Mac OS X/PowerPC64
* New platform: Mac OS X/x86_64
* New platform: Mac OS X/ARM (iPhone)
* New platform: Haiku/i386

Compiler:
* Support for Delphi-style resource handling
* Whole-program optimization infrastructure, which initially supports program devirtualization and unused virtual method removal
* Much faster compilation of units containing many type-sections
* The ability to suppress individual hints/warnings/notes
* Several improvements to the DWARF debug information generation
* Fixes to the generics support
* Fixes to the interface delegation (implements) support
* Improved cpu register allocation
* Improved ARM/EABI support

RTL:
* Linearly scaling multi-threaded memory manager
* Support for (advisory) file locking on Unix-based platforms when using the SysUtils file creation/opening routines
* Support for ANSI ISO Extended Pascal ReadStr/WriteStr
* A UnicodeString type that, while not yet equivalent to Delphi 2009's UnicodeString type, offers reference counted UnicodeString support on the Windows, Linux, Mac OS X, FreeBSD and Beos/Haiku platforms.

Packages:
* Many improvements to the XML units
* Many improvements to the database units
* Updated the common Mac OS X Pascal interfaces to r241, including header a translation of the CFNetwork framework
* The zipper unit now works correctly on big endian platforms

See http://bugs.freepascal.org/changelog_page.php for the list of reported bugs which have been fixed in this release.

****************************************************************************** What's New in 2.2.3
******************************************************************************

Free Pascal 2.2.3 contains many bug fixes and some new features. The main purpose of this release is to fix problems reported with FPC 2.2.2.

Please also see http://wiki.freepascal.org/User_Changes_2.2.4 for a list of changes which may affect the behaviour of previously working code, and how to cope with these changes.

Some highlights are:

All:
* Experimental packages-installation tool

Packages:
* Added support for TIFF reading/writing in fcl-image
* Improvements and fixes in CHM support
* Fixed linking the gtk2-package with gtk versions above 2.13.4

IDE:
* Added support for CHM help files

Documentation

See http://bugs.freepascal.org/changelog_page.php for the list of reported bugs which have been fixed in this release.

****************************************************************************** What's New in 2.2.2
******************************************************************************

Free Pascal 2.2.2 contains many bug fixes and some new features. The main purpose of this release is to fix problems reported with FPC 2.2.0, and to remove all potentially tainted code from our source code base.

Please also see http://wiki.freepascal.org/User_Changes_2.2.2 for a list of changes which may affect the behaviour of previously working code, and how to cope with these changes.

Some highlights are:

All:
* All code potentially infringing on CodeGear copyrighted code has been reimplemented using a cleanroom approach.

Platforms:
* Incompatibilities with Mac OS X 10.5's new default linker have been resolved.

Compiler:
* PIC support for Mac OS X (on by default, disable with -Cg-)
* several bugs in the experimental generics support have been fixed, but this feature is still in beta
* initialisation and finalisation of shared libraries has been fixed for all Darwin platforms, and for Linux/i386
* support for {$packset x} directive to enable set packing (use {$packset 1} for Delphi-compatible sets, but note that the format is different on little and big endian platforms)

RTL:
* thread resource leaking under unix has been fixed
* the widestring manager for unix has been completed
* several floating point to string conversion errors have been fixed
* significantly improved variant support
* implementation of RTL exception handler for OS/2 allowing proper translation of some runtime errors
* various fixes for GO32v2 improving useability of this target
* OS/2 RTL enhanced to allow seamless working with large files (64-bit file system API calls) where available (WSeB/MCP/eCS/Warp 4 with FP15)

Packages:
* the Windows API interface units have been significantly updated
* Apple universal interfaces updated to r234 of the common FPC/GPC/MW interfaces
* New TRegexEngine class to parse regular expressions

Documentation
* Documentation was updated completely to conform to the actual state of the compiler and RTL.

See http://bugs.freepascal.org/changelog_page.php for the list of reported bugs which have been fixed in this release.

****************************************************************************** What's New in 2.2.0
******************************************************************************

Free Pascal 2.2.0 contains a lot of bug fixes and new features. The work on Free Pascal 2.2.0 started halfway during the year 2005. A lot has been improved since then.

Please also see http://wiki.freepascal.org/User_Changes_2.2.0 for a list of changes which may affect the behaviour of previously working code, and how to cope with these changes.

Platforms:
* New platform: Win64. FPC is the first open source compiler for 64-bit Windows operating systems.
* New processor architecture: 64-bit PowerPC
* PowerPC/64 support for Linux
* Mac OS X on Intel (i386) is now supported
* New platform: Windows CE (Windows Mobile)
* New platform: Nintendo Game Boy Advance
* New platform: Nintendo DS
* Native support for ARM-platform
* GO32V2 DOS platform got a long needed update

Compiler:
* Internal linker for win32, win64 and wince, resulting in smaller executables, less memory used during compilation, and faster compile times for programs using large frameworks like for example the Lazarus Component Library.
* Generics (experimental)
* Bit packed arrays and records
* Resourcestrings can now be smartlinked, resulting in smaller executables
* Multiple resource files support
* pointer[low..high] syntax to pass C-style pointer arrays to procedures using open arrays
* Interface delegation
* Proper safecall implementation
* Wide strings are COM/OLE compatible on Windows
* Added several speed optimisations, for example:
* Compiler can omit stack frames (x86 and ARM)
* Compiler can store records in registers
* Tail recursion expansion
* Register renaming optimizations
* Improved optimizer for ARM CPU
* Compiler can initialise local variables, function results, and "out" parameters with several values (command line parameters -gt till -gtttt) to help find uses of uninitialised variables
* Compiler can now properly deal with paths > 255 characters in all cases
* Dwarf debug format support
* Reduced memory usage during compilation
* Lot of small bugs and compatibility fixes

RTL:
* Heap uses less memory
* Improved variants support
* Improved currency support
* Exception handling can be used without SysUtils unit
* Lot of small bug and compatibility fixes

FCL:
* Improved database support
* The obsolete sqlitedataset, interbase, fpodbc, ddg, mysqldb3 and mysqldb4 units are removed
* Lot of small bugs and compatibility fixes

Packages:
* Added a new fppkg package manager
* Improved database support
* Added Delphi compatible RichEdit unit
* Apple universal interfaces updated to r204 of the common FPC/GPC/MW interfaces
* Lot of small bugs and compatibility fixes

Free Vision:
* Now uses resourcestrings

IDE:
* Evaluate window
* Improved HTML rendering
* Improved xterm support
* Small bug fixes

Misc:
* Improved documentation
* Better cross compilation support

For a detailed list of reported bugs that are fixed in this release see the bugtracker report at http://www.freepascal.org/mantis/changelog_page.php

****************************************************************************** What's New in 2.0.4
******************************************************************************

More than 1000 changes have been made to 2.0.4 since 2.0.2. As this is a bug fix release, most are fixes for some issues, but new features and performance enhancements have been added as well.

Compiler:
* Lot of small bugs and compatibility fixes
* Updated several translations
* Improved code generation
* Improved and fixed PIC code generation
* Improved register allocation
* Improved ansistring string code generation
* Several alignment values increased so the requirements of modern processors are met better
* WINDOWS defined on all windows platforms (Win32, Win64, WinCE)
* Parameter order for methods with structured results changed (result pointer<->self swapped), please check such methods if they are implemented in assembler
* i386 compiler no longer needs environment variables set when installed on an x86_64 Linux distribution

RTL:
* Lot of small bug and compatibility fixes
* 64 bit file pointer support on most targets
* Faster integer to string conversion
* Endian conversion routines added
* Improved heap manager
* Improved ansistring routines
* PowerPC: Power3/4/5/PPC970 compatibility

FCL:
* Lot of small bugs and compatibility fixes
* Improved database support
* The interbase, fpodbc, ddg, mysqldb3 and mysqldb4 units are obsolete and replaced by the sqldb components
* Oracle support added

Packages:
* Lot of small bugs and compatibility fixes
* Improved database support
* Apple universal interfaces added

Free Vision:
* New outline unit
* Small bug fixes
* Unix: much improved video and keyboard handling
* Unix: Free Vision applications no longer need to link to libc
* Linux: grab_vcsa utility to ensure vcsa access

IDE:
* Small bug fixes
* Redesigned directories window
* Reorganised compiler options window
* Option to use Ctrl+X,C,V for cut/copy/paste

Misc:
* Improved documentation
* Better cross compilation support

****************************************************************************** What's New in 2.0.2
****************************************************************************** This is a bug fix release, so don't expect a big new feature list here. Most of the almost 700 changes made to 2.0.2 since 2.0.0 are fixes for some issues.

Compiler:
* Lot of small bugs and compatibility fixes
* Improved SSE support
* Improved inlining
* Enhanced variant support
* Embedded resource support for targets using elf32 executable format
+ Type checking of compile time expressions
+ Mode MacPas: Support for Mac style objects
+ Mode MacPas: Compile time variables can be given on command line

RTL:
* Lot of small bugs and compatibility fixes
* Enhanced variant support
* Embedded resource support for targets using elf32 executable format

FCL:
* Lot of small bugs and compatibility fixes
* Improved SqlDB package

Packages:
* Lot of small bugs and compatibility fixes
* Improved data base support

IDE:
* Small bug fixes

Misc:
* Improved docs
* Bug fixes for FreeVision

****************************************************************************** What's New in 2.0.0
****************************************************************************** Compiler:
+ properties in objects are now allowed
+ use of cmov when at least -Cppentium2 is supplied (i386+ only)
+ .p is a searched source extension in macpas mode now
* Improved MacPas mode
* Improved variant support
* Updated language files
* Improved warnings regarding uninitialised variables
* Lot of small bugs and compatibility fixes

RTL:
* Several widestring and unicode fixes
* Heavily improved variant support
* Improved threading support
* Improved 64 bit compatibility
* Lot of small bugs and compatibility fixes

FCL:
* Improved data base support
* Lot of small bugs and compatibility fixes

Packages:
+ Jedi windows api is part of the packages now
+ Windows specific units of the rtl have been moved to packages/base/winunits
+ XFree header conversions to X package added
* Endian and 64 bit fixes
* Lot of small bugs and compatibility fixes

IDE:
* Small bug fixes

Misc:
* Improved docs
* Bug fixes for FreeVision

Version 1.9.8 aka 2.0.0-Rc2

****************************************************************************** What's New in 1.9.8 aka 2.0.0-Rc2
******************************************************************************

Compiler:
+ arm-linux cross compiler for i386-linux
+ SysV style syscalls added for MorphOS
+ Exportable macros for mode MacPas
+ Support procvar declaration in parameters for mode MacPas
+ Give warning if code is never executed in while/if statements
+ Directive {$COPERATORS ON} added, synomym for -Sc
+ Check for uninitialzed from and to values in for-loop statement
+ -Fa<unit> option added to load units in a program before the uses statement is parsed
+ -vz for output to stderr
* Better support for unique types
* AfterConstruction/BeforeDestruction behaviour is now compatible with Delphi
* Better support for Widestring
* Removed {$THREADING ON} directive, threading support is always available
* Improved code generation on Sparc
* Lot of small bugs and compatibility fixes
+ On target Mac OS, resource files is supported

RTL:
+ arm Linux support
* Basic threading support moved to the system unit
* Operator ** moved to math unit; system.power removed
* Improved variant support
* Lot of small bugs and compatibility fixes
+ The unit MacOS (api to Mac OS) for target MacOS

FCL:
+ Support for Interbase/Firebird, PostgreSQL and MySQL 4.0 under windows
* Database drivers are now dynamically loaded
* The TSQLQuery is now fully editable using cached updates
* Lot of small bugs and compatibility fixes

Packages:
+ gtk2 interface units
* 64 bit compatibility fixes
* Lot of small bugs and compatibility fixes

IDE:
+ vector unit window
* x86-64 asssembler debugging support improved
* Sparc asssembler debugging support improved
* Some bug fixes

Misc:
+ txt output to fpdoc added
* some fpdoc bugs fixes
+ demo for macos

Version 1.9.6 aka 2.0.0-Rc1

****************************************************************************** What's New in 1.9.6 aka 2.0.0-Rc1
******************************************************************************

Compiler:
+ x86_64/amd64 (Linux) compiler
+ Sparc (Linux) compiler
+ PowerPC MorphOS support
+ Mac OS (classic) compiler (for MPW)
+ Netware Libc support (-Tnetwlibc)
+ Register variable support (-Or) for all targets
+ MacPas compiler mode (-Mmacpas)
* Better inlining support
* For loop variable assignment is not allowed anymore
* $fpctarget expands to <cpu>-<os> (except for 8.3 limited targets), old $target removed
* Implicit loading of Variants unit
* Lots of bug fixes

RTL:
+ x86_64/amd64 Linux support
+ Sparc Linux support
+ PowerPC MorphOS support
+ Mac OS (classic) support (except Sysutils and its dependants)
+ Netware Libc support
+ New heap manager that releases memory back to the OS
+ TThread.Synchronize support
+ utf8bidi unit
+ GetHeapStatus added
+ GetProcessID added
+ SysUtils.GetEnvironmentVariableCount and SysUtils.GetEnvironmentString added
* gpm unit does not need libgpm anymore
+ Further additions for improved Delphi compatibility
+ System.GetProcessID and System.GetThreadID added
+ Dos.GetMsCount added
+ Support for changing console resolution in Video for Win32
+ Support for using high memory (> 512 MB) under OS/2 (where available)
- Removed MaxAvail, MemAvail, HeapSize due to their unreliability (bogus/misleading return values) in multitasking environment with swapping

FCL:
+ RTTIUtils unit added
+ fpcunit test-framework added
* Lots of dbf and other db fixes

FV:
* Updated to fvision implementation, first official release

IDE:
* Lots of improvements and stability fixes
* Support latest gdb 6.2.x and 6.3.x releases

Docs:
+ Lots of updates
+ Easier to navigate html documentation
* fpDoc is used to generate all unit documentation

Misc:
* Makefiles create units in a separate directory units/cpu-os/
* More cross compilation improvements

****************************************************************************** What's New in 1.9.4 aka 2.0.0-Beta3
******************************************************************************

Compiler:
+ ARM (Linux) compiler
+ PowerPC Darwin (Mac OS X) support
+ reintroduce keyword support
+ added prefetch(const mem) support
+ MacPas compile mode
+ -gv to generate an executable that can be run under Valgrind >= 2.1
* register allocator fixes and tweaks
* better support for preprocessor $IF expressions
* better overloaded operator support
* Win32 DLL export table fixes
* stabs (debuginfo) generation cleanups
* enum names in RTTI are now in their original case
* record alignment fixes
* lots of bug fixes

RTL:
+ ARM Linux support
+ Powerpc Darwin support
+ Sysutils.RaiseLastOSError added
+ Sysutils.GetLastOSError added
+ Classes.TOwnedCollection added
+ Sysutils.FileIsReadOnly added
+ support of widestring and currency in the typinfo unit
* Better support for Libc based RTL (FPC_USE_LIBC)
* 64bit cleanup for future x86_64 port
* ExecuteProcess fixes
* Linux use getdents syscall instead of deprecated readdir
* bug fixes

FCL:
+ SDF DB backend
+ TGA support in fpImage
+ support of widestring and currency type in stream related classes
* Lot of fixes to fpImage classes

Misc:
* better cross development support
* Documentation updates
* Testsuite updates to store testrun results in a database
* Testsuite updates for cross platform testing, with remote rsh/ssh support

****************************************************************************** What's New in 1.9.2 aka 2.0.0-Beta2
******************************************************************************

Compiler:
+ PowerPC compiler
+ sse/sse2 code generation support
+ "global" property support
* improved inlining support
* optimizer enabled again
* uses register calling conventions by default
* $fputype directive
+ properties of type single can have default values
+ support of $IF DECLARED()
+ support of DQWORD in inline intel assembler code
* lots of bug fixes

RTL:
* more improvements for unix runtime library
* using FPC_USE_LIBC allows to compile an rtl which uses libc instead of syscalls
+ System.Initialize
+ Sysutils.ExecuteProcess
+ System.WideStringManager
+ System.PtrInt and System.PtrUInt
* ipv6 support
* lots of bug fixes

FCL:
+ sqlite support
* bug fixes

Misc:
* improved docs

****************************************************************************** What's New in 1.9.0 aka 2.0.0-Beta1
******************************************************************************

Compiler:
+ dynamic arrays
+ interfaces
+ variants
+ full widestring support
+ default parameters
+ cross name scope overloading
+ support for the PowerPC, Sparc and ARM processor, installation packages will follow within the next weeks
+ new and more sophisticated register allocator
+ inlining across units
+ register calling conventions
+ SSE and SSE2 support for inline assembler
+ PIC code generation
+ new language mode: "Mac Pascal"
+ full boolean evaluation is now also available
+ threadvar support, enabled by using {$threading on}
* support of int64 integer constants
* improved Delphi compatibility in -Sd mode
* a lot of bug fixes
* large parts of the compiler are rewritten to create a more stable, portable and maintainable compiler

RTL:
+ multithreading support
* completely rewritten unix runtime library
* improved Delphi compatiblity
* significantly improved speed of exception related code
* prepared for big endian and 64 Bit CPUs
* a lot of bug fixes

FCL:
+ tdataset support
+ html generator
+ 64 Bit file handling
* a lot of bug fixes

Docs:
* adapted to reflect new language features

IDE:
* a lot of bug fixes

Misc:
* improved cross compilation

Reply by email

Boris Samorodov
to Marco van de Voort
Happy New Year!

Happy New Year!

As a special present, We have placed a new major release of the Free Pascal Compiler, version 2.4.0 on our ftp-servers.

Thanks for the great work!

Show quoted text 8 lines
Changes that may break backwards compatibility are documented at: http://wiki.freepascal.org/User_Changes_2.4.0 Downloads are available at: the main FTP server at ftp://ftp.freepascal.org/pub/fpc/beta/2.4.0/

Seems that that should be ftp://ftp.freepascal.org/pub/fpc/dist/2.4.0/ (dist instead of beta)

and ftp://freepascal.stack.nl/pub/fpc/beta/2.4.0/

Seems that permissions are not correct here.
-----
% ftp ftp://freepascal.stack.nl/pub/fpc/dist/
...
ftp> pwd
Remote directory: /mirrors/fpc/dist
ftp> cd 2.4.0
550 2.4.0: Permission denied.
ftp> ls
...
drwxr-x--- 19 816 106 4096 Dec 30 14:43 2.4.0 ...
-----

WBR, bsam

Reply by email

Marco van de Voort
to Boris Samorodov

In our previous episode, Boris Samorodov said:

Show quoted text 8 lines
> Downloads are available at: > the main FTP server at > ftp://ftp.freepascal.org/pub/fpc/beta/2.4.0/ Seems that that should be ftp://ftp.freepascal.org/pub/fpc/dist/2.4.0/ (dist instead of beta)

Indeed

Show quoted text 6 lines
... ftp> pwd Remote directory: /mirrors/fpc/dist ftp> cd 2.4.0 550 2.4.0: Permission denied. ftp> ls

Fixed. We are still working on the mirrors (due to the "special" moment of releasing some bits might be a bit delayed)

Reply by email

Mark Emerson
to Marco van de Voort: Happy New Year! As a special present, We have placed a new major release of the Free…

Dear FPC Team,

THANK YOU FOR YOUR EXTRAORDINARY WORK AND DEDICATION!!!

Dunno what we would do without you!!!

Happy New Year to you all, and to all your dear ones, and to all FPC users world-wide.

May this be the year when SIGNIFICANTLY more people come to realize the FPC is the BEST general-purpose programming language.

This year begins the FIFTH decade for Pascal (developed by Wirth in 1970), and Niklaus Wirth will turn 76 this year. May this be the decade when Pascal, through FPC, becomes the language OF CHOICE for general-purpose programming by expert programmers worldwide.

Mark Emerson

am Marco van de Voort wrote 80 lines
Happy New Year! As a special present, We have placed a new major release of the Free Pascal Compiler, version 2.4.0 on our ftp-servers. Changes that may break backwards compatibility are documented at: http://wiki.freepascal.org/User_Changes_2.4.0 Downloads are available at: the main FTP server at ftp://ftp.freepascal.org/pub/fpc/beta/2.4.0/ and ftp://freepascal.stack.nl/pub/fpc/beta/2.4.0/ Enjoy! The Free Pascal Compiler Team Free Pascal Compiler Version 2.4.0 *************************************************************************** *** What's New in 2.4.0 *************************************************************************** *** Free Pascal 2.4.0 contains many fixes and new features. While we did not manage to incorporate all planned additions, we believe this release offers a nice collection of new functionality and bug fixes. Please also see http://wiki.freepascal.org/User_Changes_2.4.0 for a list of changes which may affect the behaviour of previously working code, and how to cope with these changes. Some highlights are: Platforms: * New platform: Mac OS X/PowerPC64 * New platform: Mac OS X/x86_64 * New platform: Mac OS X/ARM (iPhone) * New platform: Haiku/i386 Compiler: * Support for Delphi-style resource handling * Whole-program optimization infrastructure, which initially supports program devirtualization and unused virtual method removal * Much faster compilation of units containing many type-sections * The ability to suppress individual hints/warnings/notes * Several improvements to the DWARF debug information generation * Fixes to the generics support * Fixes to the interface delegation (implements) support * Improved cpu register allocation * Improved ARM/EABI support RTL: * Linearly scaling multi-threaded memory manager * Support for (advisory) file locking on Unix-based platforms when using the SysUtils file creation/opening routines * Support for ANSI ISO Extended Pascal ReadStr/WriteStr * A UnicodeString type that, while not yet equivalent to Delphi 2009's UnicodeString type, offers reference counted UnicodeString support on the Windows, Linux, Mac OS X, FreeBSD and Beos/Haiku platforms. Packages: * Many improvements to the XML units * Many improvements to the database units * Updated the common Mac OS X Pascal interfaces to r241, including header a translation of the CFNetwork framework * The zipper unit now works correctly on big endian platforms See http://bugs.freepascal.org/changelog_page.php for the list of reported bugs which have been fixed in this release.

Reply by email

Doug Chamberlin
to Marco van de Voort: Happy New Year! As a special present, We have placed a new major release of the Free…

Thanks for all the great work that has gone into 2.4.0!

For my new year's resolution I'm going to commit to FPC and Lazarus. So, I'm installing the latest in a fresh Ubuntu 9.10 VM and diving in. I'll be pushing all this software hard and will probably be coming here for help.

First problem: I downloaded the 32bit Linux (fpc-2.4.0.i386-linux.tar) and unpacked it into "~/ins/fpc 2.4.0" and ran "sudo ./install.sh". Immediately I ran into a problem because the directory I was installing from contained an embedded space in the name.

It really should be documented as a requirement to not have embedded spaces. Or, better yet, the install script should be updated to allow for them. Or, at least, the install script should be updated to detect them and stop gracefully.

How can we get this done?

As far as I can see there is NO documentation in the installation tarball. Just the install script. Can't a readme file be added with this little detail?

Doug C. ----- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Doug Chamberlin
to Doug Chamberlin

Sorry about all the cross posting. I didn't think such cross posting was typically used and didn't even think to check the reply-to addresses.

Problem #2: I decided to make a contribution by adding a note to the installation docs about needing to install from a location without embedded spaces in the directory path. I went to the www.freepascal.org and could not find any suitable place.

So I went to the wiki and could not find any area dedicated to installation issues.

So I went to the community area and found the forum "Installing Free Pascal". Now this forum lists "Ask a question" but no "Post a tip". I suppose I could ask a question and also then answer it but that seems a bit convoluted.

Am I missing something? Just seems there should be a better way...

Doug C. ----- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Anthony Walter
to Marco van de Voort: Happy New Year! As a special present, We have placed a new major release of the Free…

I read the user changes document which seemed to consist of a list of subtle changes. My question is does 2.4.0 put forward any major changes and if so in what document are those changes described. I am interested in reading about changes such as official generic support, changes to support COM variants or interfaces, and other language changes such as closures etc.

Reply by email

Jonas Maebe
to Anthony Walter
Anthony Walter wrote
I read the user changes document which seemed to consist of a list of subtle changes. My question is does 2.4.0 put forward any major changes and if so in what document are those changes described.

There's the included "whatsnew.txt" document (whose contents were also posted as part of the announcement), but it's fairly high level. There is currently no detailed list in the same style as the user changes document.

I am interested in reading about changes such as official generic support,

Slightly better than in 2.2.4, but still not finalised.

changes to support COM variants or interfaces,

No idea.

and other language changes such as closures etc.

Unavailable (I don't think anyone is even working on that).

Jonas

Reply by email

Paul Ishenin
to Jonas Maebe
Jonas Maebe wrote 6 lines
and other language > changes such as closures etc. > Unavailable (I don't think anyone is even working on that).

What is this? Any document to read about 'closures'?

Best regards,
Paul Ishenin.

Reply by email

Jonas Maebe
to Doug Chamberlin: Thanks for all the great work that has gone into 2.4.0! For my new year's resolution I'm…
Doug Chamberlin wrote
For my new year's resolution I'm going to commit to FPC and Lazarus. So, I'm installing the latest in a fresh Ubuntu 9.10 VM and diving in. I'll be pushing all this software hard and will probably be coming here for help.

Then this is indeed the place to be!

Show quoted text 5 lines
First problem: I downloaded the 32bit Linux (fpc-2.4.0.i386-linux.tar) and unpacked it into "~/ins/fpc 2.4.0" and ran "sudo ./install.sh". Immediately I ran into a problem because the directory I was installing from contained an embedded space in the name. It really should be documented as a requirement to not have embedded spaces. Or, better yet, the install script should be updated to allow for them. Or, at least, the install script should be updated to detect them and stop gracefully. How can we get this done?

Please file a bug report at http://bugs.freepascal.org

As far as I can see there is NO documentation in the installation tarball. Just the install script. Can't a readme file be added with this little detail?

Please file another bug report at http://bugs.freepascal.org :)

Jonas

Reply by email

Jonas Maebe
to Doug Chamberlin: Sorry about all the cross posting. I didn't think such cross posting was typically used…
Doug Chamberlin wrote 5 lines
Problem #2: I decided to make a contribution by adding a note to the installation docs about needing to install from a location without embedded spaces in the directory path. I went to the www.freepascal.org and could not find any suitable place. So I went to the wiki and could not find any area dedicated to installation issues. So I went to the community area and found the forum "Installing Free Pascal". Now this forum lists "Ask a question" but no "Post a tip". I suppose I could ask a question and also then answer it but that seems a bit convoluted.

You don't have to take it that literally, you can also directly post a comment/tip.

Jonas

Reply by email

Juha Manninen
to Doug Chamberlin: Thanks for all the great work that has gone into 2.4.0! For my new year's resolution I'm…
Doug Chamberlin wrote 20 lines
For my new year's resolution I'm going to commit to FPC and Lazarus. So, I'm installing the latest in a fresh Ubuntu 9.10 VM and diving in. I'll be pushing all this software hard and will probably be coming here for help. First problem: I downloaded the 32bit Linux (fpc-2.4.0.i386-linux.tar) and unpacked it into "~/ins/fpc 2.4.0" and ran "sudo ./install.sh". Immediately I ran into a problem because the directory I was installing from contained an embedded space in the name. It really should be documented as a requirement to not have embedded spaces. Or, better yet, the install script should be updated to allow for them. Or, at least, the install script should be updated to detect them and stop gracefully. How can we get this done? As far as I can see there is NO documentation in the installation tarball. Just the install script. Can't a readme file be added with this little detail?

I also looked at FPC page and wiki page and there are no instructions for installation! How is it possible?
The only link for FPC installation is buried under Lazarus documentation (!) : http://www.stack.nl/~marcov/buildfaq.pdf
which is even too detailed as the wiki page mentions.

Things are easy if there is a distro package for FPC. I am sure the main distros will have a package for fpc 2.4.0 in few days.

Otherwise, installation should be documented. I never installed from a tar pack but I did install the latest development version from SVN. It was easy to install by running "make all" and "make install". But, it was not documented! I made a guess and started "make all" and then asked from this list if I am doing the right thing. The answer was: Yes.
Why can't there be a README.TXT file at SVN root directory saying it?

Also, spaces in directory names should be allowed because the file system allows them. If not, then this limitation should be documented clearly.

Regards,
Juha Manninen

Reply by email

Jonas Maebe
to Juha Manninen
Juha Manninen wrote
I also looked at FPC page and wiki page and there are no instructions for installation! How is it possible?

The readme.txt that's normally included with every FPC installation package does include installation instructions for most platforms. The fact that it's apparently not included in the Linux tarball is a bug.

Why can't there be a README.TXT file at SVN root directory saying it?

It's not that there can't be such a file, it's just that nobody has written one. Feel free to submit one!

In general, the actual repository used for building FPC releases is the fpcbuild repository (http://svn.freepascal.org/svn/fpcbuild/trunk/; it incorporates the regular fpc repository via an "external" reference). That one does contain an INSTALL and README file in the install subdirectory (although they are somewhat outdated in some respects, e.g., the INSTALL one still refers to cvs), which describes how to create an installer for several (but not all, although Linux is included) platforms and which also lists a number of options that can be used when building/installing via the makefile.

Jonas

Reply by email

Michael Van Canneyt
to Juha Manninen: I also looked at FPC page and wiki page and there are no instructions for installation!…
Juha Manninen wrote 27 lines
On lauantai, 2. tammikuuta 2010 04:53:16 Doug Chamberlin wrote: > For my new year's resolution I'm going to commit to FPC and Lazarus. So, > I'm installing the latest in a fresh Ubuntu 9.10 VM and diving in. I'll > be pushing all this software hard and will probably be coming here for > help. > > First problem: I downloaded the 32bit Linux (fpc-2.4.0.i386-linux.tar) > and unpacked it into "~/ins/fpc 2.4.0" and ran "sudo ./install.sh". > Immediately I ran into a problem because the directory I was installing > from contained an embedded space in the name. > > It really should be documented as a requirement to not have embedded > spaces. Or, better yet, the install script should be updated to allow > for them. Or, at least, the install script should be updated to detect > them and stop gracefully. > > How can we get this done? > > As far as I can see there is NO documentation in the installation > tarball. Just the install script. Can't a readme file be added with this > little detail? I also looked at FPC page and wiki page and there are no instructions for installation! How is it possible? The only link for FPC installation is buried under Lazarus documentation (!) : http://www.stack.nl/~marcov/buildfaq.pdf which is even too detailed as the wiki page mentions.

I guess you didn't read the documentation then.

It is published on the website:

http://www.freepascal.org/docs-html/user/user.html

Chapter 2 is all about installing.

In particular, section 2.2.1 says something about installing in a directory containing spaces in its name:

http://www.freepascal.org/docs-html/user/usersu3.html

Show quoted text 10 lines
Things are easy if there is a distro package for FPC. I am sure the main distros will have a package for fpc 2.4.0 in few days. Otherwise, installation should be documented. I never installed from a tar pack but I did install the latest development version from SVN. It was easy to install by running "make all" and "make install". But, it was not documented! I made a guess and started "make all" and then asked from this list if I am doing the right thing. The answer was: Yes. Why can't there be a README.TXT file at SVN root directory saying it?

Because it is so obvious that no-one bothered to document it in an extra file. If you made it to the point that you extracted the source from SVN, you should know what to do next.

If I see a makefile, I always do 2 things:
make all
make install
If I see a 'configure' script, I do
configure --help
and after studying the options:
./configure --options-I-need
Which normally leaves me with the makefile. At which point: see above.

This is general programming knowledge. Someone who doesn't know that should not be installing from sources or attempt recompiling a compiler: they should use a pre-packaged version instead. If they want to try anyway: Sure, and it is a great learning experience. For those that want to learn, compiling the compiler is treated in the programmer's reference:

http://www.freepascal.org/docs-html/prog/progap6.html

So saying that it is not documented is overstretching it a bit.

Michael.

Reply by email

Joost van der Sluis
to Juha Manninen: I also looked at FPC page and wiki page and there are no instructions for installation!…
Juha Manninen wrote
On lauantai, 2. tammikuuta 2010 04:53:16 Doug Chamberlin wrote: Things are easy if there is a distro package for FPC. I am sure the main distros will have a package for fpc 2.4.0 in few days.

Problem with that is that for distro's which also include programs written in fpc, it is not really possible to update the compiler between two distro releases. Because it'll mean that those related programs can behave differently if they are rebuild for some minor update or something.

Imagine that the gcc-version in a distro will be updated in a update. It'll affect (almost) all packages. This can't be done...

But most distro's have a 'testing' or development branch. You can try there...

Show quoted text 6 lines
Otherwise, installation should be documented. I never installed from a tar pack but I did install the latest development version from SVN. It was easy to install by running "make all" and "make install". But, it was not documented! I made a guess and started "make all" and then asked from this list if I am doing the right thing. The answer was: Yes. Why can't there be a README.TXT file at SVN root directory saying it?

For this release, there are also deb anr rpm files, offcourse.

Joost

Reply by email

Juha Manninen
to Michael Van Canneyt: I guess you didn't read the documentation then. It is published on the website:…
Michael Van Canneyt wrote 12 lines
I guess you didn't read the documentation then. It is published on the website: http://www.freepascal.org/docs-html/user/user.html Chapter 2 is all about installing. In particular, section 2.2.1 says something about installing in a directory containing spaces in its name: http://www.freepascal.org/docs-html/user/usersu3.html

Well yes. Somehow I missed it now. I have looked at the User's guide earlier though.

Show quoted text 12 lines
Because it is so obvious that no-one bothered to document it in an extra file. If you made it to the point that you extracted the source from SVN, you should know what to do next. If I see a makefile, I always do 2 things: make all make install If I see a 'configure' script, I do configure --help and after studying the options: ./configure --options-I-need Which normally leaves me with the makefile. At which point: see above.

Ok. In this case it could have been more difficult because of the "cycle build" thing FPC does. It wasn't more difficult which is good.

Show quoted text 9 lines
This is general programming knowledge. Someone who doesn't know that should not be installing from sources or attempt recompiling a compiler: they should use a pre-packaged version instead. If they want to try anyway: Sure, and it is a great learning experience. For those that want to learn, compiling the compiler is treated in the programmer's reference: http://www.freepascal.org/docs-html/prog/progap6.html So saying that it is not documented is overstretching it a bit.

Right, my bad.
I think the problem for me was that I want to experiment something quickly and only read brief instructions. Then I maybe try again and finally read documents if nothing else helps. It is not the right way, I know.

1. I want to download. I could easily find download instructions. There is a "Download" link at freepascal main page. Both packages and SVN are covered.

2. I want to install. There is no link saying "Installation". Even if you select the Documentation link and search for "install" you don't find anything.
The installation stuff is "buried" in User's guide and Programmer's guide. I missed it and so apparently did the original poster of this thread. (So it is not only me.)

Juha Manninen

Reply by email

Anthony Walter
to Paul Ishenin: Looks as something related to: http://en.wikipedia.org/wiki/Anonymous_function#Delphi ?…
Paul Ishenin wrote 11 lines
Jonas Maebe wrote: > > http://edn.embarcadero.com/article/33336 > > Note that even Delphi doesn't have them yet ("it might also turn up in > Delphi in the future"). > Looks as something related to: http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then this is already implemented in delphi.

Something I've really found useful in C#/.NET is lamda functions and capturing locals (closures). This feature really solves asynchronous design for you can follow this code (note below how url and dimension locals are captured):

// inside a static class called Async ...
public delegate object Task();
public delegate void Complete(object result);
public static void Execute(Task task, Complete complete) { ... }

Which can then lead to code like this:

downloading = true;
progressControl.Status = ProgressStatus.Busy;
Async.Execute(() => Download.BitmapScaled(url, maxWidth, maxHeight),
DownloadComplete);

... and in DownloadComplete:

private void DownloadComplete(object result)
{

  downloading = false;
  progressControl.Status = ProgressStatus.None;
  if (result is Exception)
    progressControl.Text = "An error occurred during download";
  else
  {
    progressControl.Text = String.Empty;
    imageControl.Image = result as Bitmap;
  }

}

Reply by email

Doug Chamberlin
to Michael Van Canneyt: I guess you didn't read the documentation then. It is published on the website:…
Michael Van Canneyt wrote 20 lines
> On Sat, 2 Jan 2010, Juha Manninen wrote: > I also looked at FPC page and wiki page and there are no instructions for > installation! How is it possible? > The only link for FPC installation is buried under Lazarus > documentation (!) : > http://www.stack.nl/~marcov/buildfaq.pdf > which is even too detailed as the wiki page mentions. I guess you didn't read the documentation then. It is published on the website: http://www.freepascal.org/docs-html/user/user.html Chapter 2 is all about installing. In particular, section 2.2.1 says something about installing in a directory containing spaces in its name: http://www.freepascal.org/docs-html/user/usersu3.html

Two things:
1) Yes, the Users Guide has installation instructions in Chapter 2. However, it warns only to not install the software into directories that contain embedded spaces. It does NOT warn about untarring the tarballs into such directories. It should.

2) Having the installation instructions in the Users Guide is appropriate for software that is distributed via CD or DVD. You can browse the files directly and pull off the PDF and read it before doing anything else.

For downloaded software there should be instructions in the very first download about where to find detailed installation instructions. Better yet, they should just be right there in front of you when you need them.

Furthermore, if the installation instructions are to be kept in the Users Guide, right on the download page should be a note to download that first and read Chapter 2 before proceeding.

Doug C. ----- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Jonas Maebe
to Doug Chamberlin
Doug Chamberlin wrote
1) Yes, the Users Guide has installation instructions in Chapter 2. However, it warns only to not install the software into directories that contain embedded spaces. It does NOT warn about untarring the tarballs into such directories.

That's because this was an (unknown) bug.

It should.

Not anymore. In fact, the warning about not installing in a directory with a space can also be removed now (at least for Linux).

Jonas

Reply by email

Doug Chamberlin
to Jonas Maebe
Jonas Maebe wrote 9 lines
On 02 Jan 2010, at 21:56, Doug Chamberlin wrote: > 1) Yes, the Users Guide has installation instructions in Chapter 2. However, it warns only to not install the software into directories that contain embedded spaces. It does NOT warn about untarring the tarballs into such directories. That's because this was an (unknown) bug. > It should. Not anymore. In fact, the warning about not installing in a directory with a space can also be removed now (at least for Linux).

Many thanks for the quick fix, Jonas.

Anyone know how soon this will be incorporated into the tar file that is posted as the latest 2.4 download?

Doug C. ----- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Florian Klaempfl
to Doug Chamberlin
Show quoted text 20 lines
Jonas Maebe wrote: > On 02 Jan 2010, at 21:56, Doug Chamberlin wrote: > >> 1) Yes, the Users Guide has installation instructions in Chapter 2. >> However, it warns only to not install the software into directories >> that contain embedded spaces. It does NOT warn about untarring the >> tarballs into such directories. > > That's because this was an (unknown) bug. > >> It should. > > Not anymore. In fact, the warning about not installing in a directory > with a space can also be removed now (at least for Linux). Many thanks for the quick fix, Jonas. Anyone know how soon this will be incorporated into the tar file that is posted as the latest 2.4 download?

Never. 2.4.0 is out and finished.

Reply by email

Florian Klaempfl
to Lou James
I still didn't find out where to get the 2.4.0 version for iphone.. Shouldn't it be under ARM/Mac OS X?

No. The directories are named by host operating system so the arm-macosx cross compiler is in
ftp://ftp.freepascal.org/pub/fpc/dist/2.4.0/i386-macosx/

Reply by email

Lou James
to Florian Klaempfl

Oh I see.
Thanks && Happy New Year!~

2010/1/3 Florian Klaempfl

Show quoted text 11 lines
Lou James schrieb: > I still didn't find out where to get the 2.4.0 version for iphone.. > Shouldn't it be under ARM/Mac OS X? No. The directories are named by host operating system so the arm-macosx cross compiler is in ftp://ftp.freepascal.org/pub/fpc/dist/2.4.0/i386-macosx/ _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
樓洵(AquarHEAD) ---------- Blossoms which were the joys that fell, And leaves, the hopes that yet remain. ---------- http://www.AquarHEAD.com Sent from Jiamusi, 23, China

Reply by email

Peter W A Wood
to Paul Ishenin: Looks as something related to: http://en.wikipedia.org/wiki/Anonymous_function#Delphi ?…
Show quoted text 6 lines
Jonas Maebe wrote: > http://edn.embarcadero.com/article/33336 > > Note that even Delphi doesn't have them yet ("it might also turn up in Delphi in the future"). > Looks as something related to: http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then this is already implemented in delphi.

From my understanding, Delphi's so-called "Anonymous Functions" work as closures - the inner function/procedure having access to the variables of the outer function/procedure even if the outer function has completed execution. Delphi's anonymous functions can have names so they don't seem to be so anonymous. Anonymous functions were implemented in Delphi 2009.

Apparently, they are referred to as anonymous functions as the term closures is used for something different in C++ Builder.

Regards

Peter

Reply by email

Florian Klaempfl
to Peter W A Wood
Show quoted text 19 lines
> Jonas Maebe wrote: >> http://edn.embarcadero.com/article/33336 >> >> Note that even Delphi doesn't have them yet ("it might also turn >> up in Delphi in the future"). >> > Looks as something related to: > http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then > this is already implemented in delphi. From my understanding, Delphi's so-called "Anonymous Functions" work as closures - the inner function/procedure having access to the variables of the outer function/procedure even if the outer function has completed execution. Delphi's anonymous functions can have names so they don't seem to be so anonymous. Anonymous functions were implemented in Delphi 2009. Apparently, they are referred to as anonymous functions as the term closures is used for something different in C++ Builder.

I still don't get what's the real use of such constructs? I see only that it seems to encourage a hacky scripting language like coding style?

Reply by email

Michael Van Canneyt
to Florian Klaempfl
Florian Klaempfl wrote 24 lines
Peter W A Wood schrieb: >> Jonas Maebe wrote: >>> http://edn.embarcadero.com/article/33336 >>> >>> Note that even Delphi doesn't have them yet ("it might also turn >>> up in Delphi in the future"). >>> >> Looks as something related to: >> http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then >> this is already implemented in delphi. > > From my understanding, Delphi's so-called "Anonymous Functions" work > as closures - the inner function/procedure having access to the > variables of the outer function/procedure even if the outer function > has completed execution. Delphi's anonymous functions can have names > so they don't seem to be so anonymous. Anonymous functions were > implemented in Delphi 2009. > > Apparently, they are referred to as anonymous functions as the term > closures is used for something different in C++ Builder. I still don't get what's the real use of such constructs? I see only that it seems to encourage a hacky scripting language like coding style?

Or like Javascript. That one gives me a headache when just looking at it :(

I don't understand what is so bad about having to name a function ? OK, in C or languages where you have only 1 namespace this may require some thinking.

But pascal has 'local' functions, so they don't pollute your namespace. If coded in an object, it's just a private method if you want. And if not that, you can code it in the implementation part of your unit. Plenty of possibilities, and you always have readable code.

Michael.

Reply by email

Marco van de Voort
to Michael Van Canneyt

In our previous episode, Michael Van Canneyt said:

Show quoted text 13 lines
> I still don't get what's the real use of such constructs? I see only > that it seems to encourage a hacky scripting language like coding style? Or like Javascript. That one gives me a headache when just looking at it :( I don't understand what is so bad about having to name a function ? OK, in C or languages where you have only 1 namespace this may require some thinking. But pascal has 'local' functions, so they don't pollute your namespace. If coded in an object, it's just a private method if you want. And if not that, you can code it in the implementation part of your unit. Plenty of possibilities, and you always have readable code.

That only worked hackingly, since procvars are for globals only. So you must check yourself that they are local, and TV/Objects then calls them with some hackery. And you can never pass local and global procs to the same procvar.

Though I don't like the anonymous in-line declaration any more than you do probably, and if D2009 hadn't come along I would have been more in favour of fixing this the ISO pascal way.

Reply by email

Doug Chamberlin
to Florian Klaempfl: Never. 2.4.0 is out and finished.
Florian Klaempfl wrote 5 lines
Doug Chamberlin schrieb: > Anyone know how soon this will be incorporated into the tar file that is > posted as the latest 2.4 download? Never. 2.4.0 is out and finished.

OK. anyone know when this fix will be incorporated into the next tarball posted to be the latest 2.4.x download?

(Pedantic, thy name is Florian! ;))

Doug C. ----- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing in e-mail?

Reply by email

Vincent Snijders
to Doug Chamberlin
Doug Chamberlin wrote 10 lines
Florian Klaempfl wrote: > Doug Chamberlin schrieb: >> Anyone know how soon this will be incorporated into the tar file that is >> posted as the latest 2.4 download? > > Never. 2.4.0 is out and finished. OK. anyone know when this fix will be incorporated into the next tarball posted to be the latest 2.4.x download?

With fpc 2.4.2. AFAIK, it has not yet been scheduled, so at earliest next autumn, that is my guess.

Vincent

Reply by email

Juha Manninen
to Anthony Walter: Something I've really found useful in C#/.NET is lamda functions and capturing locals…
Anthony Walter wrote 15 lines
On Sat, Jan 2, 2010 at 5:44 AM, Paul Ishenin wrote: > Jonas Maebe wrote: >> http://edn.embarcadero.com/article/33336 >> >> Note that even Delphi doesn't have them yet ("it might also turn up in >> Delphi in the future"). > > Looks as something related to: > http://en.wikipedia.org/wiki/Anonymous_function#Delphi ? If so then this > is already implemented in delphi. Something I've really found useful in C#/.NET is lamda functions and capturing locals (closures). This feature really solves asynchronous design for you can follow this code (note below how url and dimension locals are captured):

Right.
Anonymous functions are implemented in Delphi2009. The name is misleading because the essential thing is not being nameless but to capture data at the moment the function is defined (not when it's called). It really should be called "closure" like other languages call it.

I remember one explanation that a closure is like a reversed object. An object has data and then functions which can work on that data. A closure is a function that encapsulates data itself.

It is used in functional programming languages and needs a different mindset than traditional pascal programming. I haven't really used it. However, some other new features make it interesting.

1. Generics containers. I found an article:
http://www.drbob42.com/examines/examinA5.htm

The first examples are stupid but Generics.Defaults is interesting. I used Delphi2009 for a while and looked at its generics containers. It is innovative although I didn't fully understand the code.

2. Making multithreading easier. This will be very important in future as processors have many cores. I copy a section from this Delphi help page: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/anonymousmethods_xml.html

Regards,
Juha Manninen

Copied text:
--------------------------------------------------------- Using Code for a Parameter

Anonymous methods make it easier to write functions and structures parameterized by code, not just values.

Multithreading is a good application for anonymous methods. if you want to execute some code in parallel, you might have a parallel-for function that looks like this:

type
  TProcOfInteger = reference to procedure(x: Integer);
procedure ParallelFor(start, finish: Integer; proc: TProcOfInteger);

The ParallelFor procedure iterates a procedure over different threads. Assuming this procedure is implemented correctly and efficiently using threads or a thread pool, it could then be easily used to take advantage of multiple processors:

procedure CalculateExpensiveThings;
var
  results: array of Integer;
begin
  SetLength(results, 100);
  ParallelFor(Low(results), High(results),
    procedure(i: Integer)                           // \
    begin                                           //  \ code block
      results[i] := ExpensiveCalculation(i);        //  /  used as parameter
    end                                             // /
    );
  // use results
  end;

Contrast this to how it would need to be done without anonymous methods: probably a "task" class with a virtual abstract method, with a concrete descendant for ExpensiveCalculation, and then adding all the tasks to a queue--not nearly as natural or integrated.

Here, the "parallel-for" algorithm is the abstraction that is being parameterized by code. In the past, a common way to implement this pattern is with a virtual base class with one or more abstract methods; consider the TThread class and its abstract Execute method. However, anonymous methods make this pattern--parameterizing of algorithms and data structures using code--far easier.
-----------------------------------------------------------

Reply by email

Anthony Walter
to Juha Manninen

I'll just repeat what I said in the FPC 2.4.0 release thread.

* See the good news note at the bottom of this message

Something I've really found useful in C#/.NET is lambda functions and capturing locals (closures). This feature solves asynchronous design for me in so many ways. If you can follow the code at the bottom of this reply, and note how url and dimension locals are captured.

IMO, the key to asynchronous programming usability is be able to wrap up a calls neatly. Lambda functions allow for delayed execution of arbitrary strongly typed methods/functions. More so than anonymous methods, because you may omit the tedious and unnecessary work of defining callback signatures and saving parameters.

With a simple declaration such as "delegate object Task();" I can capture any method imaginable as a lambda. If I want to download and resize images in a background thread, I simply use a lambda to declare "() => Download.BitmapScaled(url, scale)". This is converted to a variable of type Task. The Task BitmapScaled returns an Bitmap (or Exception) object which can then be accessed in the Complete callback as result under the context of the main thread. Nothing could be better IMO.

Something to note about this form of lambda, it depends on a unified type system. That is to say, a model where all things derive from a single base object (classes, records, events, etc).

// inside a static class called Async ...
public delegate object Task();
public delegate void Complete(object result);
public static void Execute(Task task, Complete complete) { ... }

Which can then lead to code like this:

downloading = true;
progressControl.Status = ProgressStatus.Busy;
Async.Execute(() => Download.BitmapScaled(url, scale), DownloadComplete);

... and in DownloadComplete:

private void DownloadComplete(object result)
{
downloading = false;
progressControl.Status = ProgressStatus.None;
if (result is Exception)

   progressControl.Text = "An error occurred during download";

else
{

   progressControl.Text = String.Empty;
   imageControl.Image = result as Bitmap;

}
}

The good news is: Yesterday I managed to squeeze some of this into Delphi 7 in a hacked sort of way.

Reply by email