Icon+Unicon/Intro: Difference between revisions

Line 131:
 
==== procedure ====
 
Procedures are also data types that can be assigned both to and from. This allows for interesting capabilities such as tracing built-in functions, inserting a processing wedge around a procedure, creating procedures that can apply arbitrary functions, and modifying the behavior of procedures in more radical ways.
 
Consider the following code snippet which sets the variable verbose to the procedure write if any argument is "--verbose" or 1 (effectively a no-operation) otherwise:
<lang Icon> if !arglist == "--verbose" then verbose := write else verbose := 1
...
verbose("Some verbose mode diagnostic message :",var1, var2)
</lang>
 
Examples of parametrized procedures can be found in [[Sorting algorithms/Bubble sort#Icon and Unicon]] and [[Apply a callback to an array#Icon and Unicon]].
 
==== objects (unicon) ====
Objects (mutable)
Anonymous user