Examples of structure passing in Icon |
|
Here are some small programs that illustrate passing data structures to Icon procedures:
procedure main()
L := [ 1, 2, 3 ]; # Set L to a list of 3 small integers
Change_All ( L ); # This procedure does not affect L
every write ( ! L ); # Display the values of L
Change_One ( L ); # This procedure changes the first element of L
every write ( ! L ); # Display the values of L
end
procedure Change_All ( foo ) # This does not affect the caller's foo...
foo := 86; # ...because we are not changing...
end # ...a PART of an aggregate
procedure Change_One ( foo ) # This procedure affects the caller's foo...
foo[1] := 99; # ...because we are changing...
end # ...a PART of an aggregate
|
John Shipman, john@nmt.edu
Last updated: 1996/01/06 21:12:57 UT URL: http://www.nmt.edu/tcc/help/lang/icon/passexamp.html |
|