ebook img

Towards Interactive Object-Oriented Programming PDF

0.08 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Towards Interactive Object-Oriented Programming

IEICETRANS.??,VOL.Exx–??,NO.xxXXXX200x 1 LETTER Towards Interactive Object-Oriented Programming Keehang KWON†, Kyunghwan PARK††, Nonmembers, and Mi-Young PARK†, Member 3 1 0 SUMMARY To represent interactive objects, we propose a D ::= A:=G|x=E |∀x D |D∧D |D⊔D 2 choice-disjunctivedeclarationstatementoftheformS⊔Rwhere n S,Rarethe(procedureorfield)declarationstatements withina a class. This statement has the following semantics: request the Intherulesabove,oisanobjectname,xisafieldname, J usertochooseonebetweenS andRwhenanobjectofthisclass E is an expression, and A represents a procedure (or a is created. This statement is useful for representing interactive 9 objects thatrequireinteractionswiththeuser. method) of the form p(t1,...,tn). The notation x=E 2 key words: interactions, object-oriented, computability logic. in G denotes an assignment statement. A D-formula is called a class definition. The no- ] L 1. Introduction tation x = E in D denotes a field x with an initial P value E. The notation A := G in D denotes a proce- . Interactiveprogramming[4],[5]isanimportantmodern dure declaration where G is called a procedure body. s c trend in information technology. Despite much popu- The notation D∧D denotes a conjunction of two D- [ larity, object-oriented languages [6]–[8] have tradition- formulas. ally lackedmechanisms for representing interactive ob- In the transition system to be considered, G- 1 v jects. For example, an object like a lottery ticket is formulas will function as the main program (or pro- 6 in a superposition state of several possible values and cedure bodies), and a set of tuples ho,Di where o is 3 requirefurtherinteractionswiththeenvironmenttode- an object name and D is a D-formula will constitute a 8 termine their final value. program. 6 To represent interactive objects, we propose to We will present an operational semantics for this . 1 adopt a choice-disjunctive operator in computability language via a proof theory. The rules are formalized 0 logic [1],[2]. To be specific, we allow, within a class by means of what it means to execute the main task 3 definition,achoice-disjunctivedeclarationstatementof G from a program P. These rules in fact depend on 1 : the form S ⊔R. This statement has the following se- the top-level constructor in the expression, a property v mantics: requestthe user to chooseonebetweenS and known as uniform provability[3]. Below the notation Xi R when an object is created. This statement is use- ho,Di;P denotes{ho,Di}∪P butwiththeho,Dituple ful for representing interactive objects. For example, a being distinguished (marked for backchaining). Note r a lottery ticket, declared as value=$0⊔ value=$1M, thatexecutionalternatesbetweentwophases: thegoal- indicatesthatithastwopossiblevalues,nothingorone reductionphase(onewithoutadistinguishedtuple)and milliondollars,anditsfinalvaluewillbedeterminedby the backchaining phase (one with a distinguished tu- the environment (or the user). ple). The notation S sand R denotes the following: The remainder of this paper is structured as fol- execute S and execute R sequentially. It is consid- lows. We describe the new language Javai in the next ered a success if both executions succeed. The nota- section. In Section 3, we present some examples. Sec- tion o.G represent an association of o with every field tion 4 concludes the paper. or procedure name appearing in G. For example, if G is p(t1,...,tn), then o.G represents o.p(t1,...,tn). 2. The Language Definition 1. Let o be an object name, let G be a main task and let P be a program. Then the notion The language is a subset of the core (untyped) Java ofexecuting hP,o.Gi successfully andproducing a new with some extensions. It is described by G- and D- program P′– ex(P,o.G,P′) – is defined as follows: formulas given by the syntax rules below: (1) ex(ho,(A := G)i;P,A,P′) if ex(P,o.G,P′) . % G::= A|x=E |G;G|o=new D matching procedure for A is found (2) ex(ho,∀xDi;P,A,P′) if ex(ho,[t/x]Di;P,A,P′). †The authors are with Computer Eng., DongA Univ., % argument passing Korea. {khkwon,openmp}@dau.ac.kr ††The author is with Computer Eng., DongA Univ. kh- (3) ex(ho,D1 ∧ D2i;P,A,P′) if ex(ho,D1i;P,A,P′). [email protected]. The corresponding author. % looking for the procedure A in D1. IEICETRANS.??,VOL.Exx–??,NO.xxXXXX200x 2 (4) ex(ho,D ∧ D i;P,A,P′) if ex(ho,D i;P,A,P′). 1 2 2 % looking for the procedure A in D 5. Acknowledgements 2 (5) ex(P,o.A,P′)ifho,Di∈P andex(ho,Di;P,A,P′). This work was supported by Dong-A University Re- % a procedure call in object o search Fund. (6) ex(P,o.x=E,P′)whereP′ isobtainedfromP by first evaluating E to E′ and updating the value of References the field x to E′ in the object o. [1] G.Japaridze,“Introduction tocomputabilitylogic”,Annals (7) ex(P,G ;G ,P ) if ex(P,G ,P ) sand ofPureandAppliedLogic,vol.123,pp.1–99, 2003. 1 2 2 1 1 ex(P ,G ,P ). [2] G.Japaridze,“Sequential operatorsincomputabilitylogic”, 1 2 2 InformationandComputation,vol.206,No.12,pp.1443-1475, (8) ex(P,o = new D,{ho,D′i} ∪ P) where D′ 2008. [3] D.Miller,G.Nadathur,F.Pfenning,andA.Scedrov, “Uni- is obtained from D by first removing choice- formproofsasafoundationforlogicprogramming,”Annals disjunctions and then by initializing its fields. % ofPureandAppliedLogic,vol.51,pp.125–157, 1991. object creation [4] Lynn Andrea Stein, “Interactive programming: revolution- izing introductory computer science,” ACM Comput. Surv. If ex(P,G,P1) has no derivation, then the machine re- 28,4es,ArticleNo.103,December1996. turnsthe failure. Inthe above,the rules(1)to (4)deal [5] RolyPerera,“First-orderinteractiveprogramming,”12thin- with the backchaining phase, whereas the rules (5) to ternational conference on Practical Aspects of Declarative Languages (PADL’10), Springer-Verlag, Berlin, Heidelberg, (8) deal with the goal reduction phase. Our opera- pp.186-200,Jan.2010. tional semantics is a standard one appearing in most [6] Avinash C. Kak, Programming with Objects: A Compar- textbooks. Only the rule (8) is a novel feature. ative Presentation of Object-Oriented Programming with C++ and Java, John Wiley & Sons, Inc., New York, NY, 3. Examples USA,2003. [7] Joseph Albahari,and BenAlbanhari, C#5.0Pocket Refer- ence, O’ReillyMedia,224pages,May2012. ImagineTempleUniversitycharges$5,000asitstuition [8] Joshua Bloch, Effective Java, Second Edition, Addison- for nonemployees and $3,000 for employees. An exam- Wesley,346pages,May2008. ple of this class is provided by the following program: class TempleU tuition=0 ∧ (employee=true⊔employee=false) ∧ (comp tuition():=if employeethen tuition=$3000 else tuition=$5000) void main() TempleU p=new TempleU; comp tuition(); print(p.tuition) In the above, creating a TempleU object via the new construct basically proceeds as follows: the machine asks the user “are you an employee?”. If the user an- swers yes by choosing the left disjunct, employee will be initialized to true and the machine will eventually print $3000 for its tuition. If the user answers no by choosingtherightdisjunct, employeewillbeinitialized tofalseandthemachinewilleventuallyprint$5000for itstuition. Ourlanguagethusmakesitpossibletocus- tomize the amount for tuition via interaction with the user. 4. Conclusion In this paper, we have considered an extension to the core Java with disjunctive statements within a class definition. Thisextensionallowsstatementsoftheform S⊔R whereS,Rarestatements. Thesestatementsare particularly useful for representing interactive objects.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.