A fauna of functions

Red's built-in functions can be categorized as follows. The type is indicated within ():

  • operators (op!), which can be used with infix notation, such as a + b, a / b, and so on.
  • native (native!) functions, such as if, either, while, throw, all, wait, and so on; you can see a complete list by using ? op! in the console.
  • routine (routine!) functions, such as exists?, write-clipboard, and so on; you can see a list using ? routine! It is also used in Red to define a function that calls a Red/System function (see Chapter 10, Advanced Red).
  • action (action!) functions, such as copy, move, clear, to, form, and so on; you can see a complete list using ? action!

The native, routine, and action functions are written in Red/System. Action functions are special in that they are polymorphic—they are defined for more than one datatype. Which action code is executed depends on the type of its first argument.

  • mezzanine (function!) functions, which are higher-level functions written in Red; you can see a complete list using ? function!

In this section, we'll cover the variety of ways that exist to define your own functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.17.40