This section describes the functions necessary for adding an instance of <task> to a <task-list>, and removing a <task> from a <task-list>. These functions are called by the callback functions frame-add-task and frame-remove-task, respectively. Because these functions do not use any DUIM code, they are described only briefly.
Add the code described in this section to task-list.dylan.
The code for add-task is as follows:
define function add-task
(task-list :: <task-list>, task :: <task>) => ()
add!(task-list.task-list-tasks, task);
task-list.task-list-modified? := #t
end function add-task;
This function takes two arguments, a <task-list> and the <task> that is to be added to it, and returns no values. The add-task function first adds the <task> to the end of the sequence bound to the task-list-tasks slot of the <task-list>, and then sets the task-list-modified? slot of the <task-list> to #t, to indicate that a change in the <task-list> has occurred.
The code for remove-task is as follows:
define function remove-task
(task-list :: <task-list>, task :: <task>) => ()
remove!(task-list.task-list-tasks, task);
task-list.task-list-modified? := #t
end function remove-task;
This function is analogous to add-task. It takes the same arguments, and returns no values. The function first removes the <task> from the task-list-tasks slot of the <task-list>, and then sets the task-list-modified? slot of the <task-list> to #t, to indicate that a change in the <task-list> has occurred.