anuragraghavan / franca

Automatically exported from code.google.com/p/franca
0 stars 0 forks source link

Relax restrictions on order of elements in a Franca interface #104

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently Franca IDL has a defined order for the elements of an interface 
(attributes, methods, broadcasts, contract, types). This should be relaxed. It 
showed in real-world use cases that esp. for big interface definitions it would 
be helpful to group the interface elements in a way specific to the application 
at hand, and not be forced by the tool to a predefined order.

Previously, it was the assumption that reviewers can understand interfaces 
better if they know in which "section" of the definition they have to look for 
in order to find an attribute, or a method, or another interface element. 
However, it is uncommon to search for element of a given type, so we can relax 
the restriction.

Original issue reported on code.google.com by klaus.birken@gmail.com on 20 May 2014 at 12:00

GoogleCodeExporter commented 9 years ago
It has to be decided yet if the order of interface elements should be like this:

O1: (attribute|method|broadcast)* (contract)? (constant|type)?

or like this:

O2: (attribute|method|broadcast|contract|constant|type)?

or like this:

O3: (attribute|method|broadcast|constant|type)? (contract)?

I tend to option O3, rationale: It would be useful to define constants and 
types before the attributes/methods/broadcasts which use them. And the contract 
is based on the definition of the other interface elements, not vice versa. So 
the contract should be at the end. 

----

For backward compatibility, we probably should implement O3b with a deprecated 
marking at the contract, if it is not at the end:

O3b: (attribute|method|broadcast|constant|type)? (contract)? (constant|type)?

Original comment by klaus.birken@gmail.com on 20 May 2014 at 12:03

GoogleCodeExporter commented 9 years ago
Implementation sketch by Markus Mühlbrandt (slightly adapted):

FInterface returns FInterface:
    {FInterface}
    (comment=FAnnotationBlock)?
    'interface' name=ID
        ('extends' base=[FInterface|FQN])?
        ('manages'
            managedInterfaces+=[FInterface|FQN]
            (',' managedInterfaces+=[FInterface|FQN])*
        )?
    '{'
        ('version' version=FVersion)?
        (attributes+=FAttribute | methods+=FMethod |
broadcasts+=FBroadcast | types+=FType | constants+=FConstantDef)*
        (contract=FContract)?       
    '}';

Original comment by klaus.birken@gmail.com on 20 May 2014 at 12:05

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 9 Dec 2014 at 10:10

GoogleCodeExporter commented 9 years ago
Implemented by commit 4497780 on develop. We also allow constant and type 
definitions in a type collection to be in arbitrary order.

Now, a contract should be always at the end of an interface definition. 
However, we support constant and type definitions after the contract, but their 
location will be marked as deprecated (warning).

Original comment by klaus.birken@gmail.com on 15 Dec 2014 at 2:42

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 19 Dec 2014 at 2:33

GoogleCodeExporter commented 9 years ago

Original comment by klaus.birken@gmail.com on 25 Jan 2015 at 11:16