The differences between classic and modern WebScript syntax are summarized below:
Classic:
- submit { // <body> }
Modern:
function submit() { // <body> }
Classic:
- takeValuesFromRequest:(WORequest *)request inContext:(WOContext *)context { // <body> }
Modern:
//Note: no static typing allowed. function takeValues(fromRequest:= request inContext:= context){ // <body> }
Classic:
[self doIt];
Modern:
self.doIt();
Classic:
[guests addObject:newGuest];
Modern:
guests.addObject(newGuest);
Classic:
[guests insertObject:newGuest atIndex:anIndex];
Modern:
guests.insert(object := newGuest, atIndex := anIndex);Note that in this last example the left parenthesis should occur at a break between words when the modern message maps to an existing Objective-C method (which, of course, follows classic WebScript syntax). When WebScript transforms modern to classic syntax internally, it capitalizes this character before concatenating the keywords of the selector. Thus, any of the following are correct:
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