Fep Collections
As I was working on the PHP classes that Fep was to map to, I realized that it was rather silly for me to re-invent an API for lists since there were already many well-designed ones in existence. In particular, I've found that the .NET 3.5 collections API to be particularly nice to use. Moreover, since everyone and their dog and using .NET now, it would also be familiar to most programmers. Thus, I've decided to use a subset of the .NET collections API for Fep collections.
Furthermore, after some thought, I've decided to split up Fep arrays. In PHP arrays aren't really arrays in the traditional sense, but more like array/associate array hybrids (JavaScript uses a similar concept). This can be confusing, error-prone and I don't think that the benefits of having an hybrid array system outweighs the complexity.
Thus, in Fep, there will be two main collection types: lists and dictionaries. Here's how a Fep list will look like:
// Fep
fep = [ "foo", 1, 2, "bar" ];
fep.count(); // == 4
fep.add( "baz" );
fep.find( x => x > 1 ); // == 2
// Will compile into this PHP
$fep = new FepList("foo", 1, 2, "bar");
$fep->count();
$fep->add( "baz" );
$fep->find( function( $x ) { return x > 1 } );
And here's how a Fep dictionary will look:
// Fep
fep = { blah: "blah", foo: "bar", 0: "zero" };
fep.keys(); // == [ "blah", "foo", 0 ]
fep.containsKey( "foo" ); // == true
fep.remove( "foo" ); // == true
// PHP
$fep = new FepDict(array("blah" => "blah", "foo" => "bar",
0 => "zero"));
$fep->keys();
$fep->containsKey( "foo" );
$fep->remove( "foo" );