ModelingGenericFunctions - GazeboHub/lupine-m2 GitHub Wiki

Modeling Common Lisp Generic Functions in MOF

Conceptual Overview

Common Lisp generic functions represent a special class of functions within ANSI Common Lisp. In one mode of view, Common Lisp generic functions may represent a sort of hybridization of the Common Lisp function type and the semantics of the Common Lisp Object System (CLOS), essentially defining the concept of a funcallable object with CLOS semantics.

Modeling Overview

In regards to modeling Common Lisp Generic Functions within an MOF-based modeling tool, we may initially develop a sort of hack onto UML, in the form of a UML Profile in which the following properites are defined:

  • Generic Function, as a stereotype generalized as an MOF Metaclass
  • Such that would apply to a broader class of functions in the Lupine M2 metamodel: Lambda List Element as a stereotype generalized as an MOF Attribute, with the following specializations:
    • Lambda List Keyword (e.g. the &aux element itself, if and only if that lambda list syntactic element should need to be present, directly, in a model )
      • Other Keys Classifier - the presence or absence of the &allow-other-keys keyword being an element that affects a function's signature - without in itself denoting any additional function arguments - and in a more abstract regards, also affects the function call semantics of the containing function
    • Function Arugment, with the following specializations (in regards to the broader function class - not all of these elements may be present in every type of lambda list)
      • Optional Argument
      • Rest Argument
      • Keyword Argument
      • Aux Argument
      • Env Argument
  • More in regards to the M2 metamodel: In defining the broader function class, a contained element in that class, specifically for a function's lambda list, such that that element would contain all of the arguments and keywords for the function thusly modeled
  • Probably, a metaclass named Lambda List, such that would be specialized for each type of Lambda List defined in ANSI CL, and whose type would be the type of the lambda list element of the broader function class

Considering that it may be difficult to develop a clear, succinct model with a UML metamodel appended with those elements, in stereotypes and tagged values - then, considering the significance of the syntactic order of elements in a Common Lisp lambda list of any specific kind - it may simply be more effectual to define each of those elements as an element of the Lupine M2 metamodel, directly.

Towards a Near Approximation in UML

For generic functions having no complex lambda list syntax, we may at least approximate the appearance of an M2 Generic Function class, using a typical UML Class element, in which each specializable argument to the Generic Function would be represented as an attribute to the UML class element. However, this would entail that some extraneous information would be present in the model - information not indicating anything about the modeled Common Lisp program - information such as the UML visibility and the UML type of the attribute doubling as a lambda list argument, thusly.