QVT 1.4 RTF Avatar
  1. OMG Issue

QVT14 — QVTo: Enhance ObjectExp to allow constructors invocation

  • Key: QVT14-8
  • Legacy Issue Number: 19023
  • Status: open  
  • Source: Open Canarias, SL ( Adolfo Sanchez-Barbudo Herrera [X] (Inactive))
  • Summary:


    ObjectExp seems to be an enhancement to the InstantationExp due to the additional semantics, however it gets limited due to the fact that every time we need to use it we have to define the constructor body (in constrast to the instantiation expression usage). Although, ObjectExp was conceived to inline object instantiations, this limitation is not justified.

    However, this limitation could be removed by also allowing an ObjectExp-Constructor combination, in the same way we have for InstantiationExp. The problem relies on a flaky concrete syntax which we could enhance to exploit an ObjectExp with an already defined constructor operation:

    constructor Column::ColumnConstructor (n:String,t: String)

    { name:=n; type:=t; }

    object result1 : Column (“name”, “String”);
    object result2 : Column (“age”, “Integer”);

    Providing a constructor body (from ObjectExp) and a list of arguments (from InstantiationExp) should be prohibited in both, the concrete syntax and the abstract syntax. Regarding the abstract syntax this could be expression with a constraint.

    context ObjectExp
    inv : argument->size() > 0 implies body.oclIsUndefined()

    This enhancement seems convenient with no apparent drawbacks, since the old ObjectExp usage remains valid.

    Proposed solution:

    In section add the following subsection:


    If an object expression contains a constructor body, no arguments for a constructor are allowed (and vice versa):

    context ObjectExp
    inv: argument->notEmpty() > 0 implies body.oclIsUndefined() and
    not body.oclIsUndefined() implies argument->isEmpty()

    In section add the following to the the end notation subsection:

    Similarly to InstantiationExp, an object expression could be used to invoke a constructor operation, rather than inlining a constructor body:

    object result1 : Column (“name”, “String”);
    object result2 : Column (“age”, “Integer”);

    Note that this notation allows us to use object expression to instantiate (or update) objects, while having a reusable constructor in order to initialize (or update) the properties of the object subject to be created (or updated).

    In section 8.4.7:


    <object_exp> ::= 'object' ('(' <iter_declarator> ')')? <object_declarator>


    <object_exp> ::= 'object' ('(' <iter_declarator> ')')? <object_declarator>
    (<expression_block> | '(' (<declarator_list>)? ')' )

  • Reported: QVT 1.1 — Wed, 23 Oct 2013 04:00 GMT
  • Updated: Tue, 22 Dec 2015 15:31 GMT