Title: AspectOriented Action Semantics Descriptions
1Aspect-Oriented Action Semantics Descriptions
- Luis Menezes
- University of Pernambuco
- (lcsm_at_dsc.upe.br)
2Agenda
- Action Semantics
- Aspect-oriented Programming
- Aspect-oriented Action Semantics
- Conclusions
3Action Semantics
- Formalism to describe programming languages
- Action Notation
- concepts of programming languages
- Based on English terms (intuitive)
- Hides the modeled concepts complexity
4Action Semantics
- Examples of actions
- give 1
- then
- give product(2,the given integer)
- bind x to 10
- hence
- give sum(1,the integer bound to x)
- allocate a cell
- then
- store 10 in the given cell
5Action Semantics Descriptions
- Originally AS descriptions are formed by
- Abstract Syntax
- Semantic Functions
- Semantic Entities
- This organization separates the description of
each PL concept in these modules.
6Modular Extensions
- Proposed to increase the modularity of AS
descriptions - Object Oriented AS, Component AS, Modular AS
- Descriptions formed by a set of language elements
- Each element has syntax and semantics.
- Facilitates the identification where the PL
elements are defined.
7Syntax-less Concepts
- Action Semantics descriptions translates
syntactical elements into action notation. - Some programming language concepts are not
represented by textual code in programs. - For example
- The code
- f(1 x) / y
- can be used by lazy or eager programming language
- Action Semantics Descriptions can not isolate
their descriptions in separated modules - The semantics is described inside other features
semantics
8Example
- Expressions language
- component Constant is Exp where
- syntax nnumber
- semantics give n
- component Sum is Exp where
- syntax aExpression bExpression
- semantics
- (evaluate a and then evaluate b)
- then
- give sum of them
9Example
- Lazy Expressions Language
- component LazyConstant is Exp where
- syntax number
- semantics give abstraction of give n
- component LazySum is Exp where
- syntax aExpression bExpression
- semantics
- give abstraction of (
- (evaluate a and then evaluate b)
- then
- (enact the given abstraction 1 and
then enact the given abstraction 2) - then
- give sum of them
- )
10Traditional object-oriented system developing has
a similar problem.
11Crosscutting Concern
- Crosscutting concern is a system feature that
affects other concerns - They can not be implemented in a separated module
- Difficult to insert/remove in complex systems
12Crosscutting Concern
- Example Remote Databases
- void transfer(Account src, Account dest, int
amount) - if (!src.avaliable(amount))
- throw new TransferError()
- src.whitdraw(amount)
- dest.deposit(amount)
13Crosscutting Concern
- Example Remote Databases
- void transfer(Account src, Account dest, int
amount) - try
- DataBase d connect()
- d.openTransaction()
- if (!src.avaliable(amount))
- throw new TransferError()
- d.rpc(whitdraw,src,amount)
- d.rpc(deposit,dest,amount)
- d.closeTransaction()
- catch (CommunicationError e)
- d.undo()
- throw new TransferError()
-
14Aspect-oriented Programming
- Methodology designed to modularize the definition
of crosscutting concerns - Aspects
- Identify points in the system code
- Specify how these points are affected by the
crosscutting concern implementation - Weaving Operation
- Perform the modifications described by aspects
15Weaving Operation
void transfer(Account src, Account dest, int
amount) if (!src.avaliable(amount))
throw new TransferError()
src.whitdraw(amount) dest.deposit(amount)
aspect RemoteDataBase ..
Weaving
void transfer(Account src, Account dest, int
amount) try DataBase d
connect() d.openTransaction()
if (!src.avaliable(amount)) throw
new TransferError() d.rpc(whitdraw,src,
amount) d.rpc(deposit,dest,amount)
d.closeTransaction() catch
(CommunicationError e) d.undo()
throw new TransferError()
16Aspect-oriented Action SemanticsDescriptions
- Motivation
- Use aspects to improve the modularity of action
semantics descriptions - Operators designed to support aspect-oriented
concepts in action semantics
17Advices
- Specifies a modification in the specification
- An advice can
- Modify the whole component semantics
- change semantics from x to y
- Rewrite a subterm inside the component semantics
- rewrite t1 to t2
18Advices
aspect A change semantics x to
complete and then x
component Constant is Exp where syntax
nnumber semantics give n
Weaving
component Constant is Exp where syntax
nnumber semantics
complete and then give n
19Pointcuts
- Constrains the advices
- Examples of pointcuts
- The advice acts in specific components
- inside c do a
- The advice needs a runtime condition to be
enabled. - a when c
20Advices
component Constant is Exp where syntax
nnumber semantics give n component
Identifier is Exp where syntax
iIdentifier semantic give the integer
bound to i
aspect A inside Identifier change
semantics x to complete and then
x
Weaving
component Constant is Exp where syntax
nnumber semantics give n component
Identifier is Exp where syntax
iIdentifier semantic
complete then give the
integer bound to i
21Example 1Lazy Evaluation Aspect
- compoent Constant is Exp where
- syntax number
- semantics give closure abstraction of
give n - component Sum is Exp where
- syntax aExpression bExpression
- semantics
- give closure abstraction of (
- (evaluate a and then evaluate b)
- then
- (enact the given abstraction 1 and
then - enact the given abstraction 2)
- then
- give sum of them
- )
Advice 1 Expressions gives functions instead
values
22Example 1Lazy Evaluation Aspect
- compoent Constant is Exp where
- syntax number
- semantics give closure abstraction of
give n - component Sum is Exp where
- syntax aExpression bExpression
- semantics
- give closure abstraction of (
- (evaluate a and then evaluate b)
- then
- (enact the given abstraction 1 and
then - enact the given abstraction 2)
- then
- give sum of them
- )
Advice 1 Inside Exp do change semantics
from x to give closure abstraction of
x
23Example 1Lazy Evaluation Aspect
- compoent Constant is Exp where
- syntax number
- semantics give closure abstraction of
give n - component Sum is Exp where
- syntax aExpression bExpression
- semantics
- give closure abstraction of (
- (evaluate a and then evaluate b)
- then
- (enact the given abstraction 1 and
then - enact the given abstraction 2)
- then
- give sum of them
- )
Advice 2 Evaluate the abstraction before to
execute data operations
24Example 1Lazy Evaluation Aspect
- compoent Constant is Exp where
- syntax number
- semantics give closure abstraction of
give n - component Sum is Exp where
- syntax aExpression bExpression
- semantics
- give closure abstraction of (
- (evaluate a and then evaluate b)
- then
- (enact the given abstraction 1 and
then - enact the given abstraction 2)
- then
- give sum of them
- )
Advice 2 inside Exp do rewrite give op(a)
to evaluateLazyData in a
then give op(them)
25Example 1Lazy Evaluation Aspect
- compoent Constant is Exp where
- syntax number
- semantics give n
- component Sum is Exp where
- syntax aExpression bExpression
- semantics
- (evaluate a and then evaluate b)
- then
- give sum of them
- aspect LazyEvaluation
- Inside Exp do
- change semantics from x to
- give closure abstraction of x
- inside Exp do
- rewrite give op(a) to
- evaluateLazyData in a
- then
- give op(them)
-
weaving
Lazy Expressions Language
26Example 2Static x Dynamic Binding
- Static Bindings
- component SB_FDecl is Decl where
- syntax iId () cCom
- semantics
- bind i to closure abstraction of
- semantics of c
- component SB_FCall is Com where
- syntax i Id ()
- semantics
- enact the abstraction bound to i
- Dynamic Bindings
- component DB_FDecl is Decl where
- syntax iId () cCom
- semantics
- bind i to abstraction of
- semantics of c
- component DB_FCall is Com where
- syntax i Id ()
- semantics
- enact closure the abstraction bound to i
aspect DynBind rewrite enact
x to enact closure x
aspect StaBind rewrite abstraction
of x to closure abstraction of x
27Example 2Static x Dynamic Binding
component FDecl is Decl where syntax iId
() cCom semantics bind i
to abstraction of semantics of
c component FCall is Com where syntax i
Id () semantics enact the
abstraction bound to i
aspect StaBind rewrite abstraction
of x to closure abstraction of x
aspect DynBind rewrite enact
x to enact closure x
weaving
weaving
Language with Static Bindings
Language with Dynamic Bindings
28Conclusions
- Aspects are useful to describe some programming
language concepts improve the modularity describe
- Component libraries become more generic
- Future research in this topic includes
- Implementation of tools
- Define new aspect operators and applications to
programming language research - Design an aspect-oriented library of PL concepts
29Aspect-Oriented Action Semantics Descriptions
- Luis Menezes
- University of Pernambuco
- (lcsm_at_dsc.upe.br)