Aspect-Oriented Action Semantics Descriptions
description
Transcript of Aspect-Oriented Action Semantics Descriptions
![Page 1: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/1.jpg)
Aspect-Oriented Action Aspect-Oriented Action Semantics DescriptionsSemantics Descriptions
Luis MenezesLuis Menezes
University of PernambucoUniversity of Pernambuco
![Page 2: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/2.jpg)
AgendaAgenda
Action SemanticsAction Semantics Aspect-oriented ProgrammingAspect-oriented Programming Aspect-oriented Action SemanticsAspect-oriented Action Semantics ConclusionsConclusions
![Page 3: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/3.jpg)
Action SemanticsAction Semantics
Formalism to describe programming Formalism to describe programming languageslanguages
Action NotationAction Notation concepts of programming languagesconcepts of programming languages Based on English terms (intuitive)Based on English terms (intuitive) Hides the modeled concepts complexityHides the modeled concepts complexity
![Page 4: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/4.jpg)
Action SemanticsAction Semantics
Examples of actions:Examples of actions:
| give 1| give 1thenthen| give product(2,the given integer)| give product(2,the given integer)
| bind “x” to 10| bind “x” to 10hencehence| give sum(1,the integer bound to “x”)| give sum(1,the integer bound to “x”)
| allocate a cell| allocate a cellthenthen| store 10 in the given cell| store 10 in the given cell
![Page 5: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/5.jpg)
Action Semantics Action Semantics DescriptionsDescriptions
Originally AS descriptions are formed Originally AS descriptions are formed by:by: Abstract Syntax Abstract Syntax Semantic FunctionsSemantic Functions Semantic EntitiesSemantic Entities
This organization separates the This organization separates the description of each PL concept in description of each PL concept in these modules. these modules.
![Page 6: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/6.jpg)
Modular ExtensionsModular Extensions
Proposed to increase the modularity of AS Proposed to increase the modularity of AS descriptionsdescriptions Object Oriented AS, Component AS, Modular Object Oriented AS, Component AS, Modular
ASAS Descriptions formed by a set of language Descriptions formed by a set of language
elementselements Each element has syntax and semantics.Each element has syntax and semantics.
Facilitates the identification where the PL Facilitates the identification where the PL elements are defined.elements are defined.
![Page 7: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/7.jpg)
Syntax-less ConceptsSyntax-less Concepts
Action Semantics descriptions translates Action Semantics descriptions translates syntactical elements into action notation.syntactical elements into action notation.
Some programming language concepts are not Some programming language concepts are not represented by textual code in programs. represented by textual code in programs.
For example:For example: The code: The code:
f(1 + x) / yf(1 + x) / y can be used by lazy or eager programming language can be used by lazy or eager programming language
Action Semantics Descriptions can not isolate Action Semantics Descriptions can not isolate their descriptions in separated modulestheir descriptions in separated modules The semantics is described inside other features The semantics is described inside other features
semanticssemantics
![Page 8: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/8.jpg)
ExampleExample
Expressions language:Expressions language:
component Constant is Exp wherecomponent Constant is Exp where
syntax = [[ n:number ]] syntax = [[ n:number ]]
semantics = give nsemantics = give n
component Sum is Exp wherecomponent Sum is Exp where
syntax = [[ a:Expression “+” b:Expression ]]syntax = [[ a:Expression “+” b:Expression ]]
semantics = semantics =
(evaluate a and then evaluate b)(evaluate a and then evaluate b)
thenthen
give sum of themgive sum of them
![Page 9: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/9.jpg)
ExampleExample
Lazy Expressions Language:Lazy Expressions Language:
component LazyConstant is Exp wherecomponent LazyConstant is Exp where syntax = [[ number ]] syntax = [[ number ]] semantics = semantics = give abstraction of give abstraction of give ngive n
component LazySum is Exp wherecomponent LazySum is Exp where syntax = [[ a:Expression “+” b:Expression ]]syntax = [[ a:Expression “+” b:Expression ]] semantics = semantics = give abstraction of (give abstraction of ( (evaluate a and then evaluate b)(evaluate a and then evaluate b) thenthen (enact the given abstraction # 1 and then enact the given abstraction (enact the given abstraction # 1 and then enact the given abstraction
#2)#2) thenthen give sum of themgive sum of them ))
![Page 10: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/10.jpg)
Traditional object-oriented Traditional object-oriented system developing has a system developing has a
similar problem….similar problem….
![Page 11: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/11.jpg)
Crosscutting ConcernCrosscutting Concern
Crosscutting concern is a system Crosscutting concern is a system feature that affects other concernsfeature that affects other concerns
They can not be implemented in a They can not be implemented in a separated moduleseparated module
Difficult to insert/remove in complex Difficult to insert/remove in complex systemssystems
![Page 12: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/12.jpg)
Crosscutting ConcernCrosscutting Concern
Example: Remote Databases:Example: Remote Databases:
void transfer(Account src, Account dest, int amount) {void transfer(Account src, Account dest, int amount) {
if (!src.avaliable(amount))if (!src.avaliable(amount))
throw new TransferError();throw new TransferError();
src.whitdraw(amount);src.whitdraw(amount);
dest.deposit(amount);dest.deposit(amount);
}}
![Page 13: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/13.jpg)
Crosscutting ConcernCrosscutting Concern
Example: Remote DatabasesExample: Remote Databases
void transfer(Account src, Account dest, int amount) {void transfer(Account src, Account dest, int amount) { try {try { DataBase d = connect();DataBase d = connect(); d.openTransaction();d.openTransaction(); if (!src.avaliable(amount))if (!src.avaliable(amount)) throw new TransferError();throw new TransferError(); d.rpc(d.rpc(whitdraw,src,amount);whitdraw,src,amount); d.rpc(d.rpc(deposit,dest,amount);deposit,dest,amount); d.closeTransaction();d.closeTransaction(); } catch (CommunicationError e) {} catch (CommunicationError e) { d.undo();d.undo(); throw new TransferError();throw new TransferError(); }}}}
![Page 14: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/14.jpg)
Aspect-oriented Aspect-oriented ProgrammingProgramming
Methodology designed to modularize the Methodology designed to modularize the definition of crosscutting concernsdefinition of crosscutting concerns
Aspects:Aspects: Identify points in the system codeIdentify points in the system code Specify how these points are affected by the Specify how these points are affected by the
crosscutting concern implementationcrosscutting concern implementation Weaving OperationWeaving Operation
Perform the modifications described by aspectsPerform the modifications described by aspects
![Page 15: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/15.jpg)
Weaving OperationWeaving Operationvoid transfer(Account src, Account dest, int amount) {void transfer(Account src, Account dest, int amount) { if (!src.avaliable(amount))if (!src.avaliable(amount)) throw new TransferError();throw new TransferError(); src.whitdraw(amount);src.whitdraw(amount); dest.deposit(amount);dest.deposit(amount);}}
aspect RemoteDataBase { …..}
Weaving
void transfer(Account src, Account dest, int amount) {void transfer(Account src, Account dest, int amount) { try {try { DataBase d = connect();DataBase d = connect(); d.openTransaction();d.openTransaction(); if (!src.avaliable(amount))if (!src.avaliable(amount)) throw new TransferError();throw new TransferError(); d.rpc(d.rpc(whitdraw,src,amount);whitdraw,src,amount); d.rpc(d.rpc(deposit,dest,amount);deposit,dest,amount); d.closeTransaction();d.closeTransaction(); } catch (CommunicationError e) {} catch (CommunicationError e) { d.undo();d.undo(); throw new TransferError();throw new TransferError(); }}}}
![Page 16: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/16.jpg)
Aspect-oriented Action Aspect-oriented Action SemanticsSemantics
DescriptionsDescriptions Motivation:Motivation:
Use aspects to improve the modularity Use aspects to improve the modularity of action semantics descriptionsof action semantics descriptions
Operators designed to support Operators designed to support aspect-oriented concepts in action aspect-oriented concepts in action semanticssemantics
![Page 17: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/17.jpg)
AdvicesAdvices
Specifies a modification in the Specifies a modification in the specificationspecification
An advice can:An advice can: Modify the whole component semanticsModify the whole component semantics
change semantics from change semantics from xx to to yy
Rewrite a subterm inside the component Rewrite a subterm inside the component semanticssemantics
rewrite trewrite t11 to t to t22
![Page 18: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/18.jpg)
AdvicesAdvicescomponent Constant is Exp where syntax = [[ n:number ]] semantics = give n
aspect A { change semantics x to | complete and then | x}
Weaving
component Constant is Exp where syntax [[ n:number ]] semantics | complete and then | give n
![Page 19: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/19.jpg)
PointcutsPointcuts
Constrains the advicesConstrains the advices Examples of pointcuts:Examples of pointcuts:
The advice acts in specific componentsThe advice acts in specific componentsinside c do ainside c do a
The advice needs a runtime condition to The advice needs a runtime condition to be enabled.be enabled.
a when ca when c
![Page 20: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/20.jpg)
AdvicesAdvicescomponent Constant is Exp where syntax = [[ n:number ]] semantics = give ncomponent Identifier is Exp where syntax = [[ i:Identifier ]] 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 = [[ n:number ]] semantics = give ncomponent Identifier is Exp where syntax = [[ i:Identifier ]] semantic = | complete then | give the integer bound to i
![Page 21: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/21.jpg)
Example 1Example 1Lazy Evaluation AspectLazy Evaluation Aspect
compoent Constant is Exp wherecompoent Constant is Exp where syntax = [[ number ]] syntax = [[ number ]] semantics = semantics = give closure abstraction of give closure abstraction of give ngive n
component Sum is Exp wherecomponent Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]]syntax = [[ a:Expression “+” b:Expression ]] semantics = semantics = give closure abstraction of (give closure abstraction of ( (evaluate a and then evaluate b)(evaluate a and then evaluate b) thenthen (enact the given abstraction # 1 and then (enact the given abstraction # 1 and then enact the given abstraction #2)enact the given abstraction #2) thenthen give sum of themgive sum of them ))
Advice 1:
Expressions gives functions instead values
![Page 22: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/22.jpg)
Example 1Example 1Lazy Evaluation AspectLazy Evaluation Aspect
compoent Constant is Exp wherecompoent Constant is Exp where syntax = [[ number ]] syntax = [[ number ]] semantics = semantics = give closure abstraction of give closure abstraction of give ngive n
component Sum is Exp wherecomponent Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]]syntax = [[ a:Expression “+” b:Expression ]] semantics = semantics = give closure abstraction of (give closure abstraction of ( (evaluate a and then evaluate b)(evaluate a and then evaluate b) thenthen (enact the given abstraction # 1 and then (enact the given abstraction # 1 and then enact the given abstraction #2)enact the given abstraction #2) thenthen give sum of themgive sum of them ))
Advice 1:
Inside Exp do change semantics from x to give closure abstraction of x
![Page 23: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/23.jpg)
Example 1Example 1Lazy Evaluation AspectLazy Evaluation Aspect
compoent Constant is Exp wherecompoent Constant is Exp where syntax = [[ number ]] syntax = [[ number ]] semantics = semantics = give closure abstraction of give closure abstraction of give ngive n
component Sum is Exp wherecomponent Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]]syntax = [[ a:Expression “+” b:Expression ]] semantics = semantics = give closure abstraction of (give closure abstraction of ( (evaluate a and then evaluate b)(evaluate a and then evaluate b) thenthen (enact the given abstraction # 1 and then (enact the given abstraction # 1 and then enact the given abstraction #2)enact the given abstraction #2) thenthen give sum of themgive sum of them ))
Advice 2:
Evaluate the abstraction before to execute data operations
![Page 24: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/24.jpg)
Example 1Example 1Lazy Evaluation AspectLazy Evaluation Aspect
compoent Constant is Exp wherecompoent Constant is Exp where syntax = [[ number ]] syntax = [[ number ]] semantics = semantics = give closure abstraction of give closure abstraction of give ngive n
component Sum is Exp wherecomponent Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]]syntax = [[ a:Expression “+” b:Expression ]] semantics = semantics = give closure abstraction of (give closure abstraction of ( (evaluate a and then evaluate b)(evaluate a and then evaluate b) thenthen (enact the given abstraction # 1 and then (enact the given abstraction # 1 and then enact the given abstraction #2)enact the given abstraction #2) thenthen give sum of themgive sum of them ))
Advice 2:
inside Exp do rewrite give op(a) to evaluateLazyData in a then give op(them)
![Page 25: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/25.jpg)
Example 1Example 1Lazy Evaluation AspectLazy Evaluation Aspect
compoent Constant is Exp wherecompoent Constant is Exp where syntax = [[ number ]] syntax = [[ number ]] semantics = give nsemantics = give n
component Sum is Exp wherecomponent Sum is Exp where syntax = [[ a:Expression “+” syntax = [[ a:Expression “+”
b:Expression ]]b:Expression ]] semantics = semantics = (evaluate a and then evaluate b)(evaluate a and then evaluate b)
thenthen give sum of themgive sum of them
aspect LazyEvaluation {aspect LazyEvaluation {Inside Exp doInside Exp do change semantics from x to change semantics from x to give closure abstraction of xgive closure abstraction of x
inside Exp doinside Exp do rewrite give op(a) torewrite give op(a) to evaluateLazyData in aevaluateLazyData in a thenthen give op(them)give op(them)
}}
weaving
Lazy ExpressionsLanguage
![Page 26: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/26.jpg)
Example 2Example 2Static x Dynamic BindingStatic x Dynamic Binding
Static BindingsStatic Bindings
component SB_FDecl is Decl component SB_FDecl is Decl wherewhere
syntax [[ i:Id “()” c:Com ]] syntax [[ i:Id “()” c:Com ]] semantics semantics
bind i to bind i to closureclosure abstraction abstraction ofof
|| semantics of c semantics of c
component SB_FCall is Com wherecomponent SB_FCall is Com where syntax [[ i :Id “()” ]]syntax [[ i :Id “()” ]] semantics semantics enact the abstraction bound enact the abstraction bound
to ito i
Dynamic BindingsDynamic Bindings
component DB_FDecl is Decl wherecomponent DB_FDecl is Decl where syntax [[ i:Id “()” c:Com ]] syntax [[ i:Id “()” c:Com ]] semantics semantics
bind i to abstraction ofbind i to abstraction of || semantics of c semantics of c
component DB_FCall is Com wherecomponent DB_FCall is Com where syntax [[ i :Id “()” ]]syntax [[ i :Id “()” ]] semantics semantics enact enact closureclosure the abstraction the abstraction
bound to ibound to i
aspect StaBind { rewrite abstraction of x to closure abstraction of x}
aspect DynBind { rewrite enact ~x to enact closure ~x}
![Page 27: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/27.jpg)
Example 2Example 2Static x Dynamic BindingStatic x Dynamic Binding
component FDecl is Decl where syntax [[ i:Id “()” c:Com ]] 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
![Page 28: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/28.jpg)
ConclusionsConclusions
Aspects are useful to describe some Aspects are useful to describe some programming language concepts improve programming language concepts improve the modularity describe the modularity describe Component libraries become more genericComponent libraries become more generic
Future research in this topic includesFuture research in this topic includes Implementation of toolsImplementation of tools Define new aspect operators and applications to Define new aspect operators and applications to
programming language researchprogramming language research Design an aspect-oriented library of PL conceptsDesign an aspect-oriented library of PL concepts
![Page 29: Aspect-Oriented Action Semantics Descriptions](https://reader036.fdocuments.net/reader036/viewer/2022070410/56814556550346895db2270a/html5/thumbnails/29.jpg)
Aspect-Oriented Action Aspect-Oriented Action Semantics DescriptionsSemantics Descriptions
Luis MenezesLuis Menezes
University of PernambucoUniversity of Pernambuco