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:(Z*([MmaTQf+}D+QnSƄcL-gH h`+8 Nj3Z N+\ WJj)'vُvgRPŸ<੷\#^;yh];  }_^7lq\"%pK ÉGvM׵`wׁ\`m7RdTdU<,eR[^QOmaEW&6TwF?}1얺e1#ƒY`$+e`&,aSԍjnp- γ?UщL*(2Q?.XDkɨ`!#sdth mԠU4&NS|T쬟 ~yv̯ˎލm.2hQ=8kFp(.ey8sI7(aCZ+tR5VѢ#2<#09fcxdX (+\{q2n5C ?4-2004-06-16 paO  =DPorting BETA to ROTOR?ROTOR Projects Presentation Day, June 16 2004 by Peter Andersen@.@ !F!The BETA programming language(rObject-oriented programming language Scandinavian school of OO, starting with the Simula languages Simple example:*%PNP%NHR f4BETA example use<  BETA vs. CLR/CLSPClass and method unified in pattern General nesting of patterns, i.e. also of methods Uplevel access to fields of outer patterns INNER instead of super Enter-Do-Exit semantics Genericity in the form of virtual patterns Multiple return values Active objects in the form of Coroutines No constructors, no overloading No dynamic exceptionsXVZ+ZZ2+,V 7K%BETA.Net/Rotor ChallengesMapping must be complete and semantically correct BETA should be able to uses classes from other languages Other languages should be able to use classes generated from BETA source code BETA should be able to inherit classes from other languages Other languages should be able to inherit from BETA The BETA mapping should be  nice when seen from other languages In .NET terminology: BETA compliant with Common Language Specification (CLS) BETA should be a CLS Extender:PVPI   The mappingGenerating bytecode for CLR mostly corresponds to making a BETA source mapping into C# source code C# used here for presentation purpose But we do generate IL (intermediate language bytecodes) directly into IL files IL files assembled with ilasm>  1 Mapping patterns: nested classes!!( $Use of add as a class:$ h Use of add as a method$ h X0"Interface to external classes etc.Pt. in a declarative manner Ex: Rudimentary support for overloading, constructors etc. Offline batch tool dotnet2beta implemented using reflection (generates BETA source files); should be part of BETA compiler System.String vs. BETA text: Automatic coercion8Zp ]0/&Not described here& @ Virtual classes  corresponding to generics (.NET 2.0   Whidbey )  implemented with virtual instantiation methods and a lot of (unnecessary) casting. Coroutines and concurrency  implemented with threads. More on this later& Pattern variables: Classes and methods as first-class values  implemented with reflection Leave/restart out of nested method activations  implemented with exceptions Multiple return values  implemented with extra fields Numerous minor details!P* V  1J @9N >  6T-Status95% of BETA language implemented Leave/restart across component border missing Coroutines and leave/restart not ideally implemented Some things need to be more  nice Not yet 100% CLS compliant E.g. custom attributes and consumption of value types Optimizations needed Large number of classes generated due to the generality of BETA !PcP>P6PP@PP!c>6@O U.Major missing detailsValue types consumption Enumeration consumption Throw and handling of CLR exceptions Consumption of static fields Support for custom attributes Maybe proc, class etc. as attributes? Leave/restart over coroutine border Support for multiple interfaces 64 bit arithmetic Boot-strapped compiler (needs some of above) Implementation of BETA class libraries Direct compiler support for reading external classes Visual Studio .NET language extensionBP&PP&.   : W/Plans for ROTOR9Simple hello-world and complete compiler test suite Hello-world and most of compiler test suite up-and-running; clix script generation added Implement (some of) above mentioned missing details Bootstrapping the BETA compiler to ROTOR and .NET Currently ongoing Develop a GUI framework on top of ROTOR and .NET. System.Windows.Forms and System.Drawing not available on ROTOR BETA traditional GUI library Lidskjalv and new OpenGL based GUI library Octopus considered Investigate support for Simula/BETA-style coroutines Modify ROTOR bytecodes/jitter/GC/class libraries? >4nZZZfnZZ2nZZ5nZ2ZnZ4<f  2\ " 52  pNv    5 "+       g5Coroutines in C#" Imagine: Do() is action part of coroutine S.call() will invoke Do() suspend() in S.Do() (or methods called from S.Do()) will return to the point of S.call() and resume execution after S.call()Z  h6Example: Adder"Produces sequence start + start, (start+1)+(start+1) & By using (infinite) recursion Suspends after each computationuZu)  j7Example: Multiplier0 Produces sequence start * start, (start+1) * (start+1) & By using (infinite) recursion Suspends after each computation8wZK+  k8MergerkMerge sequences produced by Adder instance and Multiplier instance Sort in ascending order First 6 valueslZl     o<  p=  r>  s?  t@  uA  vB  wC!Implementation of class Coroutine""(d Aclass Coroutine implemented by means of another class Component:6B"   yD!Implementation of class Component""(d ]class Component implemented by means of System.Threading.Thread and System.Threading.MonitorH^  zE"Implementation of Component.swap()"#  zUsed asymmetrically: Call: this == callee; this.caller == this Suspend: this == current; this.caller to be resumedF2F42e   {F(Implementation of Components in BETA.Net)) d Any pattern in BETA may be used as a coroutine Implemented as shown for C#, with class BetaObject used instead of class Coroutine class BetaObject is common superclass for all BETA objects Same class Component used \R 0x         |GComparison with C# 2.0 yieldJ DComing C# 2.0 has new feature called yield return Used for implementing enumerator pattern May be considered  poor mans coroutine Can only  save one stack frame    ~J,Iterators (slide borrowed from Erik Meijer)- "$ Method that incrementally computes and returns a sequence of values yield return and yield break Must return IEnumerator or IEnumerable&DDDD}H Coroutine support in .NET/ROTOR?!!$" ?Thread synchronization seems clumsy and inefficient (benchmarking pending, though) Direct user defined scheduling desirable P/Invoke of WIN32 Fibers? ROTOR extension with e.g. coswap bytecode? Addition of bytecode straight-forward Managing of thread stacks? No idea how hard that would be in ROTOR Our coming research!!|ZEZAZ(ZZ|4 A( zU ! Contacts:"Peter Andersen (that s me) mailto:datpete@daimi.au.dk Ole Lehrmann Madsen mailto:olm@daimi.au.dk Download: http://www.daimi.au.dk/~beta/ooli  # # !| 06 0Lb 0n/4&,-1 2 34<eix +  0` fff33` 3KI3ff` 33ff` /p` 3%*3|` Jy3fff3f` 3ff3̙` 33ff33` DDyq3f` ̙3n` w3ff` }ff>?" dd@,?nKd@ P nA@F`d n?" dd@   @@``PR"   @ ` `2p>>   ` (  `* ` 6 #" ``   Rotor Presentation Day0 @  ` 6 #" `` `  \Peter Andersen0  T X ` "X ` Nd#" `P > ` 6 d#" `U " ` S  "UY J 0 ` c $"YW J 0  ` c $"YU J 0  ` c $" J 0  ` S #" `SV "  ` S "Y J 0  ` c $8!"X J 0 ` <x# #" `  `  f.Klik for at redigere titeltypografi i masteren//> ` 08& " `p  hKlik for at redigere teksttypografierne i masteren Andet niveau Tredje niveau Fjerde niveau Femte niveau3  i ` 6, #" `^ `  h*0 H ` 0޽h ? }ff___PPT10i. 07+D=' = @B +  Pixel  0 u m 0d (  dT  d " d T($fd #"   > d c $\(f "9)e  "b e  d# "e  d S @+f"ie  " d S .f"9) " d S 1f"0 "  d S <5f"?e  "  d S 8f") "  d S ;f"?G "  d S 8?f"oG "  d S Bf"9G " d S lEf"iA " d S Hf"A? " d 6Lf #" `` ` f h*0  d 6Qf #" ``  f j*0  d 6Vf #" `` ` f j*0  d 0Yf "P   f f.Klik for at redigere titeltypografi i masteren// d 0t[f " P  f m5Klik for at redigere undertiteltypografien i masteren66H d 0޽h ? }ff80___PPT10. 07$ 0 4(    0Df P   f T*   0   0   P (  Pr P S (f`  `  f  P c $(f`/` <$D 0 f   P 0  "`p ,$D 0 F Calculator: (# R: @integer; set: (# V: @integer enter V do V R #); add: (# V: @integer enter V do R+V R exit R #); #);;% . d  P s  _ж_жGHxiIK)LaMNxiff8c "  ,$D 0 A pattern named CalculatorB0 V   P s  _ж_жGHIK$LMNff8c "   & ,$D 0  Static instance variable named R(!0V # P  Hf_ж_жG!HIJL KLM!Nff8c " ,$D 0 !3Internal pattern named set with an input variable VZ40 p P  _ж_жG HIJL KLM Nff8c "  j,$D 0 NInternal pattern named add with an input variable V and a return value named RrO0 H P 0޽h ?O@ P PPP }ffWO___PPT10/.P++D' = @B D' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*P%c%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*Pcs%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* P%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* P%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* P%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*P%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*P%(++0+ P0 ++0+ P0 ++0+ P0 ++0+P0 ++0+P0 +@  0  (  r  S I `  `     0 K  "`c ,$D 0 F Calculator: (# R: @integer; set: (# V: @integer enter V do V R #); add: (# V: @integer enter V do R+V R exit R #); #);;% . dl     ,$D 0  H[ gֳgֳ ?  j TC: @Calculator; X: @integer; 5 C.add Xt+*****.    `d _ж_жff8c"    Use of add as a method::0p~l ~ `   `,$D 0p   Hn gֳgֳ ? ` C: @Calculator; X: @integer; A: ^C.add; &C.add[] A[]; 5 A XD) ****|     `{ _ж_жff8c" ~   Use of add as a class::0 p    Ą _ж_жGYH"IJ K L΅MNff8c "  tC9 ,$D 0 !Creation of an instance of C.add <! 20!}   _ж_жGH:TIJ KL7KMNPff8c "  t,,$D 0 {Execution of the C.add instance 0  H  0޽h ?/   }ffU M ___PPT10- .NcU+DY ' = @B D ' = @BA?%,( < +O%,( < +DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(++0+0 ++0+ 0 ++0+0 +  0  `p(  p~ p s *@ `  `    p  6v`S" i<$D 0   H p 0޽h ? 3ff___PPT10.Y+YD^' = @B D' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p$%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p$V%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*pV%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p;%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*p;Q%(+  0 xP(  xr x S  `  `    x S  `] ` <$ 0   H x 0޽h ? }ff___PPT10.1f2+[W_D7' = @B D' = @BA?%,( < +O%,( < +DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x2%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x2k%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*xk%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x)%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x)j%(Ds' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*xj%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*x%(+8+0+x0 +   0  pt(  t~ t s *lӍ `  `    t  6Xԍ `S"  <$D 0   H t 0޽h ? 3ffJ B ___PPT10" .\@i+YD ' = @B D ' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*tc%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*tc%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*t%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*t%(++   0 tl(  x  c $ލ `,'=   B  0  TC,$D 0 public class Calculator: System.Object { public int R; public class add: System.Object { public int V; & } & }<FH5P   :  0  T ,$D 0 public class Calculator: System.Object { public int R; public class add: System.Object { public int V; public void Enter(int a) { V = a; } public void Do() { R = R + V; } public int Exit() { return R; } } & }<FHt    > l  #  t  ,$D 0B   `_ж_жD8cf B   `_ж_жDf8cF f B   `_ж_жDf8c} W f "   f _ж_жff8c"  f  p6Error: Outer R cannot be accessed from nested class!707B  Z_ж_жDf8c # f   0  TF ,$D 0 ppublic class Calculator: System.Object { public int R; public class add: System.Object { public int V; Calculator origin; public add(Calculator outer) { origin = outer; } public void Enter(int a) { V = a; } public void Do() { origin.R = origin.R + V; } public int Exit() { return origin.R; } } & }KFH4 K)   &, &  0  T,,$D 0 rpublic class Calculator: System.Object { public int R; public class add: System.Object { public int V; Calculator origin; public add(Calculator outer) { origin = outer; } public void Enter(int a) { V = a; } public void Do() { origin.R = origin.R + V; } public int Exit() { return origin.R; } } public int call_add(int V){ add A = new add(this); A.Enter(V); A.Do(); return A.Exit(); } & }<FH4 K)>(   &, &  "  Z+ _ж_ж"   N Calculator: (# R: @integer; & add: (# V: @integer enter V do R+V R exit R #); #); ~0H    *"l : ~   :~ ,$D 0"   f; _ж_жff8c" : ~  n4CLS does not allow for this to be called just add()505B  T_ж_жDf8c 0 H  0޽h ? 3ff___PPT10.\ ~b+D' = @B D]' = @BA?%,( < +O%,( < +DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(++0+0 ++0+ 0 ++0+0 ++0+ 0 +|  0 .(  r  S @[ `  `     H\ gֳgֳ ?/ ,$@ 0 C: @Calculator; X: @integer; A: ^C.add; &C.add[] A[]; 5 A X G* ***|   H(j gֳgֳ ?/  ,$@ 0 8xCalculator C = new Calculator() int X; Calculator.add A; A = new Calculator.add(C); A.Enter(5); A.Do() X = A.Exit();:y=:*b# H  0޽h ? }ff~___PPT10^. +QiED2' = @B D' = @BA?%,( < +O%,( < +D| ' =%(D$ ' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<**%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<**=%(D' =%(Dh' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<**;%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*=X%(D' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*;E%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*Xd%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*dk%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*ky%(+   0 LD (  x  c $ `q      H gֳgֳ ?@'0 P ,$@ 0 XC: @Calculator; X: @integer; 5 C.add Xt-*****. R  H gֳgֳ ?@ P ,$@ 0 <Calculator C = new Calculator() int X; X = C.call_add(5);,=**#H  0޽h ? 3ff___PPT10. m +QiED' = @B D' = @BA?%,( < +O%,( < +D ' =%(D ' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#*%(D' =%(Dh' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*-%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<**=%(+~  0 %(  r  S ` `w `   r  S  `L `     T@ _ж_жf8c" =-E  gString: ExternalClass (# _init_ArrayOfChar: cons (* constructor *) (# result: ^String; arg1: [0]@char; enter (arg1[]) exit result[] #); ... CompareTo_Object: proc (* overloaded CompareTo *) (# result: @int32; arg1: ^Object; enter (arg1[]) do 'CompareTo' -> procname; exit result #); ... do '[mscorlib]System.String' -> className; #);0  H ) H  0޽h ? }ff___PPT10i. /#+D=' = @B +  0 f(  x  c $ `     Z 0e0e `   H  0޽h ? 3ff___PPT10i. 0 L+D=' = @B +2  0 P(  r  S ( `  `     S <ʟ ` `p<$ 0   H  0޽h ? }ff___PPT10. 0I+FD' = @B DI' = @BA?%,( < +O%,( < +Ds' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*!%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*!O%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*O%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* M%(+8+0+0 +  0 :(  r  S ݟ `  `     S  ` `p   "p`PpH  0޽h ? }ff___PPT10i. @u+D=' = @B +L"  0 jb(  r  S  `  `     S  ` `<$D 0   "p`Pp  C 0Acheck_in[1],$D 0H  0޽h ? }ff___PPT10b. pL+D6' = @B D' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*4%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*4%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*8%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*8w%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*w%(D' =%(D<' =%(D' =4@BBBB%(D' =,54*3>!Bstyle.color='`B@BPB<*8D' =4@BBBB%(D' =,54*3>!Bstyle.color='`B@BPB<*8wD' =4@BBBB%(D' =,54*3>!Bstyle.color='`B@BPB<*wD4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*9%(+  0 80(  r  S  `  `     S  ` `<$ 0   p  Z_ж_жf8c"` I ,$D 0 abstract class Coroutine { // Similar to Thread ... public void call() { ... } protected void suspend() { ... } abstract void Do(); // Similar to Run() } SpecificCoroutine: Coroutine{ & } Coroutine S = new SpecificCoroutine();0    H  0޽h ? }ff  ___PPT10_ .R0+,D ' = @B D~ ' = @BA?%,( < +O%,( < +D' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* -%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*-H%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*H%(+p+0+0 ++0+0 +  0  (  r  S |* `  `   r  S T+ ` `p   w  Z0 _ж_жf8c"` , class Adder: Coroutine { public int res; int start; public Adder(int s) { start = s; } void compute(int V){ res = V+V; suspend(); compute(V+1); } public override void Do() { compute(start); } }0  ( d  H  0޽h ? }ff___PPT10i.R޿j+D=' = @B +[  0 rj(    HI  `"`  `     <I  ` `p     ZK _ж_жf8c"` , class Multiplier: Coroutine { public int res; int start; public Multiplier(int s) { start = s; } void compute(int V){ res = V*V; suspend(); compute(V+1); } public override void Do() { compute(start); } }0 ' d  H  0޽h ? }ff___PPT10i.R@ +D=' = @B +  0 ^(    Hpc  `"`  `     <4d  ` `p     Zj _ж_жf8c"`  Dclass Merger: Coroutine { Adder A = new Adder(3); Multiplier M = new Multiplier(2); public override void Do() { A.call(); M.call(); for (int i=0; i<6; i++){ if (A.res < M.res) { Console.WriteLine("A: " + A.res); A.call(); } else { Console.WriteLine("M: " + M.res); M.call(); } } } public static void Main(String[] args) { (new Merger()).call() } }0 l &<  H  0޽h ? }ff___PPT10i.RZG]+D=' = @B +:  0 !P@(    Z _ж_жg "`/  Dclass Merger: Coroutine { Adder A = new Adder(3); Multiplier M = new Multiplier(2); public override void Do() { A.call(); M.call(); for (int i=0; i<6; i++){ if (A.res < M.res) { Console.WriteLine("A: " + A.res); A.call(); } else { Console.WriteLine("M: " + M.res); M.call(); } } } public static void Main(String[] args) { (new Merger()).call() } }0 l &<  F j  jb  T _ж_жg "`j Adder Multiplier MergerJ0 2  <  ~B  N_ж_жDg ~B  N_ж_жDg "   Be  W ,$@ 0 ;M0r  @ BG HI]X  ,$@ 0"  Bԡ  "W ,$@ 0 ;A0r @ BG HI]X  ,$@ 0"  B  I,$@ 0 Amerger*02  B̪ \ ` ,$@ 0 <Do0B  0D`  ,$@ 0b @ BGtH!IO(  ,$@ 0B  Z_ж_жDԔ T  ,$D 0r @ <G HI]X  ,$@ 0B  Z_ж_жDԔ',$@ 0c   _ж_жGpHIYJAKDqLMwN/ff8c "  ,$D  0 a Coroutine 0    s _ж_жGqH@IYKSLN0MYN78ff8c " 6 ,$D 0 Method invocation00   c t _ж_жG=rH%IXKl2LMZ7ff8c " eC,$D  0 8Caller link  initially self0J H  0޽h ?     }ff%~%___PPT10^%.Rp+'D#' = @B D"' = @BA?%,( < +O%,( < +D ' =%(DK ' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' ' =%(D ' =%(D' =A@BBBB0B%(D' =1:Bhidden*o3>+B#style.visibility<*%(D' =A@BBBB0B%(D' =1:Bhidden*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*%(DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D?' =%(D' =%(D' =A@BBBB0B%(D' =1:Bhidden*o3>+B#style.visibility<*%(+0+0+ 0 ++0+0 ++0+0 ++0+0 ++0+0 ++0+0 ++0+0 ++0+0 ++0+0 ++0+0 +?  0 7/`0(  "   <ݠ  W  ;M0dr  @ <G HI]X  "   <ߠ   W  ;A0"   <`  I Amerger*02  < \ `  <Do0RB  s *D`  b  <GlHIt&  ,$@ 0  Z0 _ж_жg "`-   class Adder: Coroutine { public int res; int start; public Adder(int s) { start = s; } void compute(int V){ res = V+V; suspend(); compute(V+1); } public override void Do() { compute(start); } }  0   ( d  F j  jb  T _ж_жg "`j Adder Multiplier MergerJ0 2  <  ~B  N_ж_жDg ~B  N_ж_жDg B  Z_ж_жDԔ _ B  s *D] U ,$@ 02  <` `d,$@  0 <Do0b "  `_ж_жGmHX8I ,$@  0B # Z_ж_жDԔ4 74 ,$@ 02 $ << ,$@ 0 _Compute0b '  `_ж_жGmHUfI( ,$@ 0B ( Z_ж_жDԔ=,$@ 0B ) Z_ж_жDԔ=,$@ 0 * H_ж_ж`,$D 0 + H_ж_жd ,$D  0jr ,@ BG HI]X  jb -@ BGtH!IO(  l W cY 0 WcY,$D  0 .  | _ж_жGHI+WJ+ KLHMNff8c "`W9  Y /Call() is basically just a swap of two pointers000  B /  `_ж_жDf8c0 c9 H  0޽h ?      " $'$* +,-. }ff&((___PPT10'.Ro+X Db'' = @B D'' = @BA?%,( < +O%,( < +D%' =%(D' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*,%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*-%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*"%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*+%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*0%(D ' =%(D ' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*#%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*"%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*'%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*$%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<**%(D' =%(D|' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*)%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*)%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*)%(+p+0+0 ++0+$0 +m#  0 #i(  "  <+  W  ;M0dr @ <G HI]X  "  <l0   W  ;A0"  <`3  I Amerger*02  <7 \ `  <Do0RB   s *D`  2   <; `d <Do02  <6  _Compute0  ZF_ж_жg "`/  Jclass Merger: Coroutine { Adder A = new Adder(3); Multiplier M = new Multiplier(2); public override void Do() { A.call(); M.call(); for (int i=0; i<6; i++){ if (A.res < M.res) { Console.WriteLine("A: " + A.res); A.call(); } else { Console.WriteLine("M: " + M.res); M.call(); } } } public static void Main(String[] args) { (new Merger()).call() } }0 l  &<  F j  jb  TO _ж_жg "`j Adder Multiplier MergerJ0 2  <  ~B  N_ж_жDg ~B  N_ж_жDg B  Z_ж_жDԔ*,$D 0b @ # l_ж_жGK5HzIR?  ,$D 0b @  `_ж_жGHVIM( ,$@ 0p  H_ж_ж`p  H_ж_жd b   f_ж_жGmHUfI( v  N_ж_жW \ l g  #g ,$D 0 !  Z _ж_жGH+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#%(D' =%(Df' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*#%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(+/  0 $ .(   "   <(k  W  ;M0"   < o   W  ;A0"   <s  I Amerger*02   <\w \ `  <Do0RB   s *D`  2   <{ `d <Do02   <   _Compute0b  @  `_ж_жGHVIM(    Z@ _ж_жg "`-  class Multiplier: Coroutine { public int res; int start; public Multiplier(int s) { start = s; } void compute(int V){ res = V*V; suspend(); compute(V+1); } public override void Do() { compute(start); } } 0 ' d  F j   jV   T _ж_жg "`j Adder Multiplier Merger>0 2<  ~B   N_ж_жDg ~B   N_ж_жDg p  @ H_ж_жW \ b   Z_ж_жGlH#I  B   Z_ж_жDԔ q p   H_ж_ж`p   H_ж_жd 2   < `d,$@ 0 <Do0   H_ж_жd ,$@ 0b   T_ж_жGmHI ,$@ 0B   Z_ж_жDԔ4 R4 ,$D 02   <Ԝ ,$@  0 _Compute0   H_ж_жZ,$D  0B !  Z_ж_жDԔX ,$@  0b #  Z_ж_жGmH1I" ,$@  0B $  Z_ж_жDԔyX y,$D 0H   0޽h ?                          #  }ff___PPT10j.RQP+:D' = @B D' = @BA?%,( < +O%,( < +D ' =%(D ' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D ' =%(D ' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*! %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*# %(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* %(D' =%(Df' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*! %(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*$ %(+p+0+ 0 ++0+ 0 +!  0 !$K(  $" $ <  W  ;M0" $ <h   W  ;A0" $ <  I Amerger*02 $ <P \ `  <Do0RB $ s *D`  2  $ <H `d <Do02  $ <ã  _Compute0b  $@  `_ж_жGHVIM( p $ H_ж_ж`p $ H_ж_жd 2 $ <ɣ `d <Do0p $ H_ж_жd 2 $ <̣  _Compute0p $ H_ж_жZb $ Z_ж_жGB:HFI^  b $ Z_ж_жG`H&IF"  $ Ztգ _ж_жg "`/  Dclass Merger: Coroutine { Adder A = new Adder(3); Multiplier M = new Multiplier(2); public override void Do() { A.call(); M.call(); for (int i=0; i<6; i++){ if (A.res < M.res) { Console.WriteLine("A: " + A.res); A.call(); } else { Console.WriteLine("M: " + M.res); M.call(); } } } public static void Main(String[] args) { (new Merger()).call() } }0 l &<  F j $ jb $ T< _ж_жg "`j Adder Multiplier MergerJ0 2  <  ~B $ N_ж_жDg ~B $ N_ж_жDg B $ Z_ж_жDԔy4y,$D 0B $ Z_ж_жDԔ3,$D 0B  $ Z_ж_жDԔ#p#,$D 0B !$ Z_ж_жDԔn'nH $ 0޽h ?$ $ $ $ $$ $$$$$$$ $$$$$$ }ff  ___PPT10 .RJT+i^DX ' = @B D ' = @BA?%,( < +O%,( < +D' =%(Df' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*!$%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* $%(D' =%(Df' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<* $%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*$%(D' =%(Df' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*$%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*$%(+$  0 <4%((  (" ( <$  W  ;M0" ( <h   W  ;A0" ( <@  I Amerger*02 ( < \ `  <Do0RB ( s *D`  2  ( < `d <Do02  ( <  _Compute0p  ( H_ж_ж`p  ( H_ж_жd 2 ( <l `d <Do0p ( H_ж_жd 2 ( <  _Compute0p ( H_ж_жZb ( Z_ж_жG`H&IF"  ( Z _ж_жg "`-   class Adder: Coroutine { public int res; int start; public Adder(int s) { start = s; } void compute(int V){ res = V+V; suspend(); compute(V+1); } public override void Do() { compute(start); } }  0   ( d  F j ( jb ( T _ж_жg "`j Adder Multiplier MergerJ0 2  <  ~B ( N_ж_жDg ~B ( N_ж_жDg B ( Z_ж_жDԔ% 7% b (  `_ж_жGmHUfI( p ( H_ж_жW \ 2 ( <$)  ,$@ 0 _Compute0 !( H_ж_ж,$@ 0b "(  `_ж_жGmHI ,$D 0B #( Z_ж_жDԔ7,$@ 0B %( Z_ж_жDԔ7,$D  0H ( 0޽h ?  ( ( ( (( (((((((( ( (((((( (!((("( }ffYQ___PPT101.Rgu-+e3D' = @B D' = @BA?%,( < +O%,( < +D ' =%(D ' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*#(%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*!(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*"(%(D' =%(Df' =%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*#(%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(%(+8+0+(0 +  0 <4 ,(  ," , <\6  W  ;M0" , <:   W  ;A0" , <08  I Amerger*02 , <,B \ `  <Do0RB , s *D`  2  , <TF `d <Do02  , <4J  _Compute0p  , H_ж_ж`p  , H_ж_жd 2  , <N `d <Do0p , H_ж_жd 2 , <R  _Compute0p , H_ж_жZb , Z_ж_жG`H&IF" 2 , <DX   _Compute0p , H_ж_ж , Za _ж_жg "`/  Dclass Merger: Coroutine { Adder A = new Adder(3); Multiplier M = new Multiplier(2); public override void Do() { A.call(); M.call(); for (int i=0; i<6; i++){ if (A.res < M.res) { Console.WriteLine("A: " + A.res); A.call(); } else { Console.WriteLine("M: " + M.res); M.call(); } } } public static void Main(String[] args) { (new Merger()).call() } }0 l &<  F j , jb , To _ж_жg "`j Adder Multiplier MergerJ0 2  <  ~B , N_ж_жDg ~B , N_ж_жDg B , Z_ж_жDԔ% s% J ,  `w _ж_жGHf "   ,$@ 0 x& and so on 0 " b ,@  `_ж_жGH+B#style.visibility<*,%(D' =4@BBBB%(D' =1:Bhidden*o3>+B#style.visibility<*,%(+8+0+,0 +    0 0(  0r 0 S V`  `   r 0 S R` `p   0 T _ж_ж"`7c public abstract class Coroutine { internal Component _comp; public Coroutine(){ _comp = new Component(this); } public void call() { _comp.swap(); } protected void suspend() { _comp.swap(); } public abstract void Do(); }j0&]# %b - $ ( ( 0  _ж_жGHASIJ5KZL'UMNAXffԔ "`I ,$@ 0 ;call() and suspend() implemented using a single swap method<0<  B 0@  `_ж_жDfԔpV ,$D 0H 0 0޽h ?0 }ffg____PPT10?.R0PJ+D' = @B D' = @BA?%,( < +O%,( < +D' =%(Du' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*0%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*0%(+8+0+00 +   0 8"(  8  8 HP `"`       8 <d ` `     8 Tf_ж_ж"``< public class Component { public static Component current; private Component caller; // == this when suspended private Coroutine body; private System.Threading.Thread myThread; // notice private public Component(Coroutine b) { ... Constructor: allocate myThread starting in run; set up caller etc. } private void run() { ... Thread entry point: call body.Do()and then terminate myThread & } public void swap() { ... Main call() / suspend() handling; next slide & } }R 0_J1  , *  )h ]H 8 0޽h ? }ff___PPT10i.R0cw+D=' = @B +  0   < b (  <r < S \ `{ `   X < T _ж_ж"`6 public void swap() { lock (this){ Component old_current = current; current = caller; caller = old_current; if (!myThread.IsAlive) { myThread.Start(); } else { System.Threading.Monitor.Pulse(this); } System.Threading.Monitor.Wait(this); } }0t3 *  #" <  _ж_жGHZIKeLqMNZffԔ "`<,$D 0 'Currently executing Component/Coroutine(0(d    !l  " <$  ,$D 0 < Z_ж_жffԔ"  "  < N _ж_жf"`Cv q Swap pointers0 2" Ul s   < u ,$D 0  <  `_ж_жffԔ" (s 3  < T _ж_жf"`x  Start or resume new current0 2< [l s Z  <u \,$D 0 <  `_ж_жffԔ"  5 9 < Tػ _ж_жf"` s Z  Suspend old current0 2J < <  `MT    H < 0޽h ?< }ff  ___PPT10g .R%Vp+)D ' = @B D ' = @BA?%,( < +O%,( < +DA' =%(D' =%(D' =A@BBBB0B%(D' =1:Bvisible*o3>+B#style.visibility<*<%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*<%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<* <%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*<%(+8+0+<0 +}  0 @$(  @r @ S  Ӥ `'g   r @ S Ӥ ` `p   H @ 0޽h ? }ff___PPT10i.RK +D=' = @B +}  0  D$(  Dr D S  `  `   r D S  ` `p   H D 0޽h ? }ff___PPT10i.R+D=' = @B +   0 P PO(  P P  ``?Hyy @H1?"6?@ `NNN?N` | public class List { public IEnumerator GetEnumerator() { for (int i = 0; i < count; i++) { yield return elements[i]; } } }D Zm  P C x (Iz q11ȜȜ?`>     P 3 r4 (Iz 1?`"`   f  P  T ``?GzHDvy @1?"6?@ `NNN?N p  ,$D 0 "public IEnumerator GetEnumerator() { return new __Enumerator(this); } private class __Enumerator: IEnumerator { object current; int state; public bool MoveNext() { switch (state) { case 0: & case 1: & case 2: & & } } public object Current { get { return current; } } } t ZtH P 0޽h ? P }ffz___PPT10Z.R@+(D' = @B D' = @BA?%,( < +O%,( < +D' =%(D' =%(D8' =A@BB BB0B%(D' =1:Bvisible*o3>+B#style.visibility<* P%(D' =-g6B fade*<3<* P+8+0+ P0 +B  0 0HP(  Hr H S ` `    H S ` ` p<$D 0   H H 0޽h ? }ff*"___PPT10.R`_+YD' = @B D' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*HS%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*HS|%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*H|%(D' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*H%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*H%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*H%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*H*%(D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*H*@%(+  0 p(  r  S 4( `  `   x  c $ ) ` 6p   Pl C  C ,$D 0   `+ _ж_жff8c" C x Questions?( 0 ,"  " fA `azv3vgf_[1]e   H  0޽h ? }ff___PPT10n. p+EgDB' = @B D' = @BA?%,( < +O%,( < +D4' =%(D' =%(D' =4@BBBB%(D' =1:Bvisible*o3>+B#style.visibility<*%(+ 0  (  X  C    f  S Tf 0  f "H  0޽h ? 3380___PPT10. l0|  0 0 (  X  C      S   0   "H  0޽h ? 3380___PPT10. y3|   0 @(  X  C      S |  0    H  0޽h ? 3380___PPT10. y3|  0    (  X  C       S è  0   ` Notice: The CLS does not allow for a method to be identically named as a nested class in the same scope  this means that the method call_add() above cannot be called just add(), since there is also the nested class named add. This rule is enforced by C#. This is in contrast to Java, where an inner class is distinguished from an identically named method. Java also allows inner classes to access fields in the outer classes. ECMA 335, clause 7.5.2: CLS Rule 5: All names introduced in a CLS-compliant scope shall be distinct independent of kind, except where the names are identical and resolved via overloading. That is, while the CTS allows a single type to use the same name for a method and a field, the CLS does not. We do not actually generate the above mentioned nested classes yet, but linearize all the classes to one level. It is, however, our intension to generate proper nested classes to make BETA generated code more comprehensable when seen from other .NET languages. The call_add() method could still be called just add() (when generating IL directly) but would have to be marked as NON-cls-compliant. However, it is provided as a convenience and possibly also an optimization& . n *lXH  0޽h ? 3380___PPT10. 6|b 0 r(  X  C      S  0   tZHere s a full C# program corresponding to the previous slides: public class Calculator: System.Object { int R; public class add: System.Object { Calculator origin; public int V; public add(Calculator outer) { origin = outer; } public void Enter(int a) { V = a; } public void Do() { origin.R = origin.R + V; } public int Exit() { return origin.R; } } public void set(int V) { R = V; } public int call_add(int V){ add A = new add(this); A.Enter(V); A.Do(); return A.Exit(); } public static void Main(System.String[] args){ Calculator C = new Calculator(); int x; System.Console.WriteLine("Using add as a method"); C.set(12); x = C.call_add(5); System.Console.WriteLine(x); System.Console.WriteLine("Using add as a class"); Calculator.add A = new Calculator.add(C); C.set(17); A.Enter(13); A.Do(); x = A.Exit(); System.Console.WriteLine(x); A.V = 10; A.Do(); x = A.Exit(); System.Console.WriteLine(x); } }                     4   .   H  0޽h ? 3380___PPT10. 6| 0  (  X  C      S  0   "H  0޽h ? 3380___PPT10. 6| 0  (  X  C      S p 0   "H  0޽h ? 3380___PPT10.  8| 0 0$ (  $X $ C     $ S  0   "H $ 0޽h ? 3380___PPT10. ;|! 0 tl(  X  C    l  S 3 0   $Birger Mller-Pedersen is now professor at University of Oslo Bent Bruun Kristensen is now professor at Syddansk Universitet, Odense, Denmark Ole Lehmann Madsen is now professor at University of Aarhus, Denmark. Ole Lehmann Madsen and Peter Andersen are the two main researchers for BETA.Net.6  *<H  0޽h ? 3380___PPT10._!pű 5 0 (  X  C      S   0    H  0޽h ? 3380___PPT10.RC 0 KC4(  4X 4 C    C 4 S TL 0   EDecoupling of Coroutine and Component due to BETA: In BETA implementation, class Coroutine is really class BetaObject, the common superclass of all BETA objects. Decoupling the Component part reduces the overall object size; in practice only a few objects are used as coroutines, compared to the total amount of BETA objects.|           H 4 0޽h ? 3380___PPT10.Rr\ hTf ut@(VF_t!A$0(zI, KM1@ P!\ln<pFKT ibuW >xZepr-vo ׽r8\ȋwlmxRK. ~wOh+'0| px    (4<Porting BETA to ROTORPeter AndersenPixelPeter Andersen350Microsoft PowerPoint@pQ@@P#XSTG8;  !  y--$xx--'---$xx----$xx----$xx----$xx----$xx----$x x ----$ x x ----$ x x ----$ x x ----$ xx ----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$xx----$x x ----$ x!x! ----$!!x"x"!----$""x#x#"----$##x$x$#----$$$x%x%$----$%%x&x&%----$&&x'x'&----$''x(x('----$((x)x)(----$))x*x*)----$**x+x+*----$++x,x,+----$,,x-x-,----$--x.x.-----$..x/x/.----$//x1x1/----$11x2x21----$22x3x32----$33x4x43----$44x7x74----$77x;x;7----$;;x>x>;---'}--$II--'--$ > II> >--'--$((((--'--$''22'--'}--$>II>>--'--$''(2(2'--'--$(33((--'}--$(3 3 ((--'--$(3(3(((--'--$ 3 >>3 3--'--$3>>33--'@Arial-.  2 t 2004. "System0A-@Arial-.  2 t-.-@Arial-.  2 t06.-@Arial-.  2 t-.-@Arial-.  2 t16.-@Arial-.  2 tMpa.-@"Arial Black-.  2 t1.-@Arial-. 2 06Porting .-@Arial-. 2 0\BETA to .-@Arial-. 2 >6ROTORt .-@Arial-. 2 TROTOR Projects .-@Arial-. 2 TQ Presentation.-@Arial-.  2 T|Day.-@Arial-.  2 T,.-@Arial-. 2 _ June 16 2004.-@Arial-. !2 iby Peter Andersen.-՜.+,D՜.+,`  ( 08@H P On-screen Show4Department of Computer Science, University of rhus0! G )Times New RomanArial Wingdings Arial Black Courier NewSymbolSegoe SemiboldPixelPorting BETA to ROTORThe BETA programming languageBETA example useBETA vs. CLR/CLSBETA.Net/Rotor Challenges The mapping!Mapping patterns: nested classesUse of add as a class:Use of add as a method#Interface to external classes etc.Not described hereStatusMajor missing detailsPlans for ROTORCoroutines in C#Example: AdderExample: MultiplierMerger Slide 19 Slide 20 Slide 21 Slide 22 Slide 23 Slide 24 Slide 25"Implementation of class Coroutine"Implementation of class Component#Implementation of Component.swap())Implementation of Components in BETA.NetComparison with C# 2.0 yield-Iterators (slide borrowed from Erik Meijer)!Coroutine support in .NET/ROTOR? Contacts:  Fonts UsedDesign Template Slide Titles! 8@ _PID_HLINKSAL"http://www.daimi.au.dk/~beta/oolimailto:datpete@daimi.au.dkmailto:olm@daimi.au.dk&_ƀ0Peter AndersenPeter Andersen  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Root EntrydO)PicturesF,Current UserSummaryInformation(PowerPoint Document(DocumentSummaryInformation8