Feeds:
Posts
Comments

Archive for January, 2009

F-Script 2.0 Beta 1

F-Script 2.0 beta 1 is out (download here). Here is what’s new since the latest alpha:

Handy syntax for specifying dictionaries

Looks like this (for a dictionary with two entries):

#{key1 -> value1, key2 ->  value2}

This creates an NSMutableDictionary object.

Easy access to standard IO streams

Three globals, stdin, stdout and stderr give access to the standard IO streams. You can invoke the print: method on stdout or stderr, passing a string to output. For example:

stdout print:'hello world'

You should use this instead of the old sys log:'hello world', as the sys object is not available when developing F-Script classes.

Switching between automatic GC and reference counting

You can now choose to run F-Script.app either with automatic Objective-C garbage collection or in reference counting mode, thanks to a new option in the preference panel. Personally, I use to run with automatic garbage collection whenever I can and switch to reference counting mode when I need to load frameworks or bundles that do not support automatic garbage collection.

F-Script Anywhere

A developer preview version of F-Script Anywhere 2.0 is included in the distribution!

Updated documentation

In particular, a new tutorial, Creating Cocoa classes with F-Script, provides a quick introduction to this new feature of F-Script 2.0.

Enjoy!

Advertisements

Read Full Post »

The MacDev 2009 conference program looks great. A number of sessions are already described here. There will also be workshops and other activities. I’ll be giving a session modestly titled New Cocoa Programming Superpowers:

In some ways, we are still in infancy when it comes to harvest the enormous amount of power brought by dynamic object systems and frameworks such as Objective-C/Cocoa. Fortunately, new tools and technologies can help us. In this session, Philippe will get you up to speed with F-Script 2.0, a set of open source tools that complement Xcode and Interface Builder. You will learn how to use them, discover how they can bring Cocoa development productivity and fun to new highs, and acquire new programming superpowers not seen before on any other platform!

Read Full Post »

F-Script 2.0 Alpha 7

Alpha 7 is out (download here). Four main user visible changes:

Class instance variables

We now have support for class instance variables. In the following example, we use this capability to define a class that keeps track of how many times it has been instantiated:


MyClass : NSObject
{
  "Define the class instance variable that will keep track of allocations"
  allocationCount (class instance variable)

  "The +initialize method is handy to initialize class instance variables"
  + (void)initialize
  {
      allocationCount := 0
  }

  "Perform the allocation"
  + alloc
  {
      allocationCount := allocationCount + 1.
      ^ super alloc 
  }

  "Return how many times the class has been sent an alloc message"
  + allocationCount
  {
      ^ allocationCount
  }
}

New methods for compression

Compression and indexing used to be provided by the same methods (i.e. at: and derivatives such as at:put: and removeAt:). In F-Script 2.0, compression is done using a different set of methods: where:, where:put: and removeWhere:. Having dedicated methods for compression will make code clearer and will allow for interesting new features in a future version. Of course, the old way of doing compression still works for backward compatibility, but you are encouraged to switch to the new methods.

For those new to array programming, compression allows selecting some elements of an array. It takes an array of booleans as argument and selects the elements of the receiver whose positional matching element in the argument is true. For example, say we define the following array of numbers:


numbers := {-5, -6, 3, 4, -1, 10}

Here is how we can select the elements in our array that are positive:


numbers where: numbers > 0

Now, we remove all negative elements:


numbers removeWhere: numbers < 0

Finally, we replace elements equal to 10 by 100:


numbers where: numbers = 10 put: 100

In the end, our array is equal to {3, 4, 100}.

Mandatory return instruction

Returning a value from a method must be specified explicitly using a return instruction (a caret followed by an expression). For example, the following method returns the string ‘hello’ :


- myMethod
{
    ^ 'hello'
}

Prefixed classes

In F-Script 2.0 all public classes are now prefixed. Consequently, Array, Block, Number and System become FSArray, FSBlock, FSNumber and FSSystem. The old classes are still there for backward compatibility (with the exception of System), but are deprecated. Tricks are in place to ease the transition but if you have defined categories or subclasses, you must change them to relate to the new classes.

Read Full Post »