Article:
 |
|
Embedding F-Script into Cocoa Applications
|
| Subject: |
|
Eg.2, passing and retrieving |
| Date: |
|
2002-08-07 08:59:44 |
| From: |
|
psheldon
|
|
|
FScript source :
a at:a location = 'CHICAGO' & (a capacity >=
200)
I think it is proper to see F-Script as a meaning underneath F-Script source syntax and cocoa source syntax.
So, I believe, this translates into obj c-code:
[a at: [a location]='CHICAGO" & [a capacity] >= 200]
It is hard for me to imagine a boolean an argument of a method at: . I try to imagine.
Does this mean return a if true and nil if not true?
Does application of a script to an array get its definition as on each element from Cocoa frameworks or FScriptFramework? My bet would be the method value: has, from the pdf file on F-Script, a great syntactic generality given meaning by F-Script.
I am starting to get an intense confusion about what it means to build a framework, way above my level or perhaps something fundamental and, in hindsight obvious and wonderful.
|
Showing messages 1 through 3 of 3.
-
Re: Eg.2, passing and retrieving
2002-08-07 10:22:51
pmougin
[View]
-
thanks
2002-08-08 21:55:50
psheldon
[View]
-
thanks
2002-08-09 09:46:33
pmougin
[View]
> [a at: [a location]='CHICAGO" & [a capacity] >= 200]
Not exactly. F-Script is an array language that let you manipulates arrays as a whole, taking care of iterating though the arrays’ elements automatically. This is not the case in Objective-C, where you have to explicitly code your loops.
In this particular example, the equivalent Objective-C code would looks like:
NSArray *airplanes
.
.
.
int i, nb;
NSArray *selectedAirplanes = [NSMutableArray array];
for (i=0, nb=[airplanes count]; i < nb; i++)
{
Airplane *currentAirplane = [airplanes objectAtIndex:i];
if ([currentAirplane location] isEqualToString:@"CHICAGO"] && [currentAirplane capacity] >= 200)
[selectedAirplanes addObject:currentAirplane];
}
> Does this mean return a if true and nil if not true?
No. In the example, "a" is an array of Airplanes. And the argument passed to the "at:" method is an array of booleans, with the same number of elements than in the array "a". The result will be an array of Airplaines where only the elements in "a" that correspond to a Boolean with a value of true in the bollean array will be selected.
Phil