New in Leopard is a 64 bit Objective-C runtime and support for 64 bit in the Cocoa frameworks. F-Script 2.0 provides complete 64 bit support. You can still run in 32 bit mode and you can use the F-Script framework in 64 bit and 32 bit applications.
The F-Script API now exposes 64 bit capable interfaces, using Cocoa's
When running in 64 bit mode, F-Script 2.0 directly benefits from the features provided by the 64 bit Objective-C runtime, including the large address space, the optimized dispatch system and the new exception model. Exceptions are now C++ compatible (it is my understanding that the Objective-C and C++ exception system have been somewhat unified) and benefit from the zero-cost setup model now common in modern C++ implementations.
Let's see how we can use this exception system in F-Script. In the following F-Script code, we raise a simple exception using the standard Cocoa
(NSException exceptionWithName:'MyError' reason:nil userInfo:nil) raise
And here is the general structure of an exception handler in F-Script:
[ ... do some stuff that may raise an exception ... ] onException: [ :e | ... handle exception e ... ]
As you see, there is no special syntax. It just consists in sending the
onException: message to a block, passing another block, the exception handler, as argument. If an exception is raised during the execution of the receiver, the handler is executed with the exception object, an
NSException instance, as argument.
throw method, which was introduced in F-Script 1.3, is deprecated in F-Script 2.0. Since Cocoa now specifies that exceptions must be represented by NSException objects, this method is no longer needed, as
NSException already provides a