1 / 29

Aspect-Oriented Action Semantics Descriptions

Aspect-Oriented Action Semantics Descriptions. Luis Menezes University of Pernambuco (lcsm@dsc.upe.br). Agenda. Action Semantics Aspect-oriented Programming Aspect-oriented Action Semantics Conclusions. Action Semantics. Formalism to describe programming languages Action Notation

mahlah
Download Presentation

Aspect-Oriented Action Semantics Descriptions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Aspect-Oriented Action Semantics Descriptions Luis Menezes University of Pernambuco (lcsm@dsc.upe.br)

  2. Agenda • Action Semantics • Aspect-oriented Programming • Aspect-oriented Action Semantics • Conclusions

  3. Action Semantics • Formalism to describe programming languages • Action Notation • concepts of programming languages • Based on English terms (intuitive) • Hides the modeled concepts complexity

  4. Action 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

  5. Action 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.

  6. Modular 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.

  7. Syntax-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

  8. Example • Expressions language: component Constant is Exp where syntax = [[ n:number ]] semantics = give n component Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]] semantics = (evaluate a and then evaluate b) then give sum of them

  9. Example • Lazy Expressions Language: component LazyConstant is Exp where syntax = [[ number ]] semantics = give abstraction of give n component LazySum is Exp where syntax = [[ a:Expression “+” b:Expression ]] 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 )

  10. Traditional object-oriented system developing has a similar problem….

  11. Crosscutting 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

  12. Crosscutting 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); }

  13. Crosscutting 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(); } }

  14. Aspect-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

  15. Weaving 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(); • } • }

  16. Aspect-oriented Action SemanticsDescriptions • Motivation: • Use aspects to improve the modularity of action semantics descriptions • Operators designed to support aspect-oriented concepts in action semantics

  17. Advices • 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

  18. Advices aspect A { change semantics x to | complete and then | x } component Constant is Exp where syntax = [[ n:number ]] semantics = give n Weaving component Constant is Exp where syntax [[ n:number ]] semantics | complete and then | give n

  19. Pointcuts • 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

  20. Advices component Constant is Exp where syntax = [[ n:number ]] semantics = give n component 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 n component Identifier is Exp where syntax = [[ i:Identifier ]] semantic = | complete then | give the integer bound to i

  21. Example 1Lazy Evaluation Aspect compoent Constant is Exp where syntax = [[ number ]] semantics = give closure abstraction of give n component Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]] 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

  22. Example 1Lazy Evaluation Aspect compoent Constant is Exp where syntax = [[ number ]] semantics = give closure abstraction of give n component Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]] 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

  23. Example 1Lazy Evaluation Aspect compoent Constant is Exp where syntax = [[ number ]] semantics = give closure abstraction of give n component Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]] 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

  24. Example 1Lazy Evaluation Aspect compoent Constant is Exp where syntax = [[ number ]] semantics = give closure abstraction of give n component Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]] 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)

  25. compoent Constant is Exp where syntax = [[ number ]] semantics = give n component Sum is Exp where syntax = [[ a:Expression “+” b:Expression ]] 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) } Example 1Lazy Evaluation Aspect weaving Lazy Expressions Language

  26. Static Bindings component SB_FDecl is Decl where syntax [[ i:Id “()” c:Com ]] 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 [[ i:Id “()” c:Com ]] 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 Example 2Static x Dynamic Binding aspect DynBind { rewrite enact ~x to enact closure ~x } aspect StaBind { rewrite abstraction of x to closure abstraction of x }

  27. Example 2Static 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

  28. Conclusions • 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

  29. Aspect-Oriented Action Semantics Descriptions Luis Menezes University of Pernambuco (lcsm@dsc.upe.br)

More Related