Closed christoff-buerger closed 8 years ago
Finished and tested. The following changed in addition to the original proposal:
ast-annotation
returns a special undefined annotation value if the queried node does not have the respective annotation.ast-annotation-remove!
returns the value of the removed annotation, or the undefined annotation value if the annotation was not present.undefined-annotation?
function, which can be used to decide if a value returned by ast-annotation
or ast-annotation-remove!
is indeed the value of the respective annotation or the annotation was missing.ast-annotation?
function; instead ast-annotation
in combination with undefined-annotation?
can be used to decide if a certain annotation is present.ast-annotation-set!
throws an exception if the undefined annotation value is used as value argument. It also throws an exception if the annotation name argument is not a symbol.Note: The current implementation uses a hashtable to store for every node its annotations. This strategy is problematic because the usage of nodes as keys prohibits their garbage collection. The problem is attenuated by removing nodes from the table when their last annotation is removed. However, instead of a global annotation table, a special annotation field should be added to each node, as it was handled in the previous implementation. The field was a waste of memory though, if no annotations were used at all. In the long run, such a field could be added on demand, by leveraging on future meta-protocol facilities of RACR-meta. The general idea is to modify the RACR-specification language when loading the annotations library such that its abstract syntax tree constructors add an internal annotations field.
To simplify the core implementation of RACR and, in particular, clearly identify and elaborate the essential facilities required for meta-instantiation and reasoning (cf. issues #62 and #63 ), the existing abstract syntax tree annotation functionalities should become a separate Scheme library, that can be loaded additionally to
(racr-meta core)
if required.Since unit tests for the existing annotation facilities are missing, they have to be added to ensure correct refactoring and improve code coverage.