xTalk is a loosely defined family of scripting languages. The mother of all xTalk languages is HyperTalk, the language used by Apple's HyperCard environment. These languages are characterized by simple English-like syntaxes, using real-life metaphors on top of a Smalltalk-style image and message sending apparatus, with Pascal-style block boundaries, but a less rigid structure.
xTalk languages share a common set of basic data structures and commands, as well as the general object model, and thus allow for relative portability between each other:
A few programming languages bear surface similarities to HyperTalk and were inspired by it. However, they have object models that differ so substantially that porting code from another xTalk requires a complete rewrite:
xTalk languages all share the following basic constructs:
xTalk has Smalltalk-like messaging. To send a message, write a command or function call:
like in Pascal. This message and its parameters do not require declarations, they are resolved at runtime to the correct handler. A handler looks like
and behaves pretty much like the Pascal equivalent, except that its parameter list is variadic. If less parameters are passed to a handler than it declares in its first line, the remaining variables are filled with empty strings. If more are passed, they are quietly ignored. Instead of declaring parameters as a list after the handler name, they can also be accessed using the paramCount() and param() functions, which also gives access to the ignored parameters.
xTalk scripts are often attached to objects (HyperTalk, SuperTalk, MediaTalk, LiveCode) though not always (e.g. CompileIt!, SenseTalk). If a script does not contain a handler for a particular message it uses, the message is passed on to the owning object's script to handle. Scripts can also manually pass on a message to the parent using the 'pass' command.
All xTalks support the following basic commands:
This is the main assignment statement. Most xTalks also support 'after' or 'before' for prefixing/suffixing values to each other. They also support a 'get <value>' command that is equivalent to a put statement into a container named 'it'.
Like in Pascal, this is how a handler passes data back to the message sender. This is also valid in command handlers, where the return value will be stored in the built-in variable 'the result'.
Change the property of an object (or a range of text in its text contents) to a given value. This is used both to modify instance variables of objects, as well as apply text styles to text fields. If no object is specified, a global property of the host application itself is assumed.