Apple WebObjects 3.5 User Manual
Page 184

Chapter 10
The WebScript Language
184
Here are some of the more subtle differences between WebScript and
Objective-C:
•
You don’t need to retain instance variables in the
init
method or release them
in the
dealloc
method. In general, you never have to worry about releasing
variables. One exception: if you perform a
mutableCopy
on an object, you must
release that copy.
•
Categories must not have an
@interface
declaration in WebScript.
•
The @ in WebScript signifies the initialization of an NSString,
NSDictionary, or NSArray.
•
Instead of using operators like
@selector
, you simply enclose the selector in
double quotes ("").
•
Certain operators from the C language aren’t available in WebScript, notably
the postdecrement, postincrement, and cast operators.
•
Boolean expressions never short-circuit.
Of course, the most significant difference between Objective-C and WebScript
is that in WebScript, all variables must be objects. Some of the less obvious
implications of this are:
•
You can’t use methods that take non-object arguments (unless those
arguments are integers or floats, which WebScript converts to NSNumbers).
For example, in WebScript the following statement is invalid:
// NO!! This won’t work.NSRange is a structure.
string = [NSString substringWithRange:aRange];
Methods not declared to return void must include a return
statement
Methods aren’t required to include a return statement
Has preprocessor support
Has no preprocessor support—that is, doesn’t support
the #define, #import, or #include statements
Uses reference counting to determine when to release
instance variables
Automatically retains all instance variables for the life of
the object that owns them. Automatically releases
instance variables when the object is released.
Objective-C
WebScript