

"Modern" WebScript Syntax
WebScript supports two syntax styles. The style that you've been reading about up until now is "classic" syntax, which is based on the syntax of Objective-C. If you're more familiar with languages such as Visual Basic or Java, you may be more comfortable with the alternate syntax style, called "modern" syntax.The differences between classic and modern WebScript syntax are summarized below:
- Method Definition
Classic:
- submit { // <body> }
Modern:
function submit() { // <body> }
- Method Definition With Arguments
Classic:
- takeValuesFromRequest:(WORequest *)request inContext:(WOContext *)context { // <body> }
Modern:
//Note: no static typing allowed. function takeValues(fromRequest:= request inContext:= context){ // <body> }
- Method Invocation - No Argument
Classic:
[self doIt];
Modern:
self.doIt();
- Method Invocation - One Argument
Classic:
[guests addObject:newGuest];
Modern:
guests.addObject(newGuest);
- Method Invocation - Two or More Arguments
Classic:
[guests insertObject:newGuest atIndex:anIndex];
Modern:
guests.insert(object := newGuest, atIndex := anIndex);
super.takeValuesFrom(request := request, inContext := context); super.takeValues(fromRequest := request, inContext := context); super.take(valuesFromRequest := request, inContext := context);If you choose to use modern WebScript, there is another important caveat: You cannot have methods with variable-length argument lists. Thus, you cannot use methods such as logWithFormat: and stringWithFormat:. You can, however, mix classic and modern WebScript in the same script file.
Table of Contents
Next Section