![]() ![]() ![]() ![]() ![]() ![]() ![]() |
|||||
|
|
|||||
| Functions: the differences between value and read-only arguments | |||||
| Prerequisite Concepts | Related Syntax | ||||
The fundamental difference between value and read-only arguments is that a value argument is used to pass the result of a single expression, and read-only is used to pass an entire shelf.
Use a value argument when:
42 or foo)
a + b)
Use a read-only argument when a shelf is being passed as an argument and:
repeat over, it should likely be passed as read-only.)
In general, if none of the conditions that require a read-only argument apply, then it is probably better to make the argument a value argument.
This sample shows how to use a read-only argument to count the number of active switch values on a switch shelf, without modifying the shelf.
define counter function count-active-switches
(read-only switch switch-shelf) as
local counter active-count
set active-count to 0
repeat over switch-shelf
increment active-count when switch-shelf
again
return active-count
|
Prerequisite Concepts Functions Functions: argument classes |
Related Syntax define function value |
| ---- |