CallbackResult-class: Asynchronous callback functions

Description Objects from the Class Slots Extends Methods Note Author(s) References See Also

Description

These classes provide a way to provide structure to the concept of a function that is used as an asynchronous callback or handler. The idea is that one associates a callback function with something that generates events. When an event occurs, the callback function is invoked. We use this in the Aspell package for checking the spelling of words in a document. We pass the callback function to spellDoc. It iterates over the content of the document and when it encounters an mis-spelled word, it invokes the callback function, providing it with the mis-spelled word, its location, the entire text of the document and the speller object responsible for performing the spell-checking.

The CallbackResult class is an extension of the basic notion of a Callback function. This is used to provide a way to retrieve the “answer” when the entire processing is done. In this version, the CallbackResult provides information about which variable in the environment of the callback function contains the result. This allows the iterating function to return the result at the end rather than requiring the caller to access it separately.

We imagine that one would create derived/extended classes from these that validate the formal arguments of the specified function to match the event type. Also, one might provide methods for getResult to obtain the result from a Callback in different ways than using a named variable. For instance, it may involve dynamic computations.

Objects from the Class

Objects can be created by calls of the form new("CallbackResult", ...).

Slots

.Data:

Object of class "function". This is the callback function that is to be invoked when an event occurs.

variable:

Object of class "character". The name of the variable within the

Extends

Class "Callback", directly. Class "function", by class "Callback". Class "OptionalFunction", by class "Callback". Class "PossibleMethod", by class "Callback".

Methods

spellDoc

signature(doc = "ANY", wordHandler = "CallbackResult"): check the spelling of the contents of a document and return the results as gathered by the wordHandler object.

Note

These classes are not specific to Aspell, but are here for the moment as there is no other good place to house them. The concept does arise in many places (e.g. GUIs, XML parsing) and we will want to move the code to a general package.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

References

http://aspell.sourceforge.net

See Also

spellDoc DocSpeller


omegahat/Aspell documentation built on May 24, 2019, 1:50 p.m.