Presentation is loading. Please wait.

Presentation is loading. Please wait.

Squeak, Newsqueak, Obliq PL Seminar 10/24/2007. Of mice and menus Cardelli and Pike ’85: Squeak: a language for communicating with mice Proof-of-concept.

Similar presentations


Presentation on theme: "Squeak, Newsqueak, Obliq PL Seminar 10/24/2007. Of mice and menus Cardelli and Pike ’85: Squeak: a language for communicating with mice Proof-of-concept."— Presentation transcript:

1 Squeak, Newsqueak, Obliq PL Seminar 10/24/2007

2 Of mice and menus Cardelli and Pike ’85: Squeak: a language for communicating with mice Proof-of-concept embedded DSL for UI’s Compiles to C (single OS process) Semantics: pure, CSP, tail-recursive

3 Some combinators Send, receive: c!v, c?v Non-deterministic choice: p :: p Sequential composition: p. p Parallel composition: p & p Timeout: wait[e] p || p Escape to C: { C expression }

4 Pre-defined channels Mouse clicks: UP, DN Mouse cursor: M Enter/leave mouse region: E, L Keyboard input: K Absolute time: T

5 Example: display typing on clicks proc Mouse = DN?. M?p. moveTo!p. UP?. Mouse proc Kbd(s) = K?c. if c == NewLine then typed!s. Kbd(emptyString) else Kbd(append(s,c)) fi proc Text(p) = < moveTo?p. Text(p) :: typed?s. { drawString(s,p) }?. Text(p) > type = Mouse & Kbd(emptyString) & Text(nullPt)

6 Restrictions Fixed set of channels Fixed set of processes No real datatypes; all data manipulation in C

7 Check list Concurrency: yes Shared memory: no Parallelism: no Distributed computation: no

8 Journey to the C side Pike ’90: The implementation of Newsqueak Pike ’94: Newsqueak: a language for communicating with mice Intended for full GUI applications (in particular: window system) Semantics: CSP, higher-order(-ish), impure, no references!, tail-recursive

9 Semantics C-like types (safety? unclear) Dynamic creation of processes ( begin ), channels ( mk ) Ints, bools, chars, records, arrays First-class functions—no closures Mutable data but copying semantics!

10 Performance model Meticulously optimized driver loop Reference counting Copy-on-write Tail-recursive return ( become )

11 Closure conversion on spawn f := prog() { a:int; begin prog(){ a=1; }(); }

12 Closure conversion on spawn f := prog() { a:int; begin prog(a:int){ a=1; }(a); }

13 Check list Concurrency: yes Shared memory: no Parallelism: no Distributed computation: no

14 Obliq: distributed lexical scope Cardelli ’95: Obliq: a language with distributed scope Target applications: “Distributed scripting”— telecollaboration, telemarketing, navigation Semantics: local mutable objects but roaming closures, threads and locks

15 Distributed lexical scope Objects and variables are mutable Objects never migrate; passed by reference Migrated references become network references Cloning is possible; always explicit Closures can migrate, too Free variables become network references

16 Example: computation server (* Site A *) var q = proc() end; net_export("computeServer", Namer, { rexec => meth(self, p) q := p; p() end }); q; q(); (* Site B *) let cs = net_import("computeServer", Namer); var x = 3; cs.rexec(proc() x := x+1 end); x; is now 4 is now 5 is now proc() x := x+1 end

17 Agents Distributed programming idiom Migrate both state (“suitcase”) and computation (continuation) Receive local information (“briefing”) upon migrating to new site

18 Agents let rec agent = proc(suitcase, briefing) (* work at the current site *) (* decide where to go next *)... (* run agent at nextSite with suitcase *) hop(nextSite, agent, suitcase); end;

19 Agents let hop = proc(agentServer, agent, suitcase) agentServer( proc(briefing) fork(proc() agent(copy(suitcase), briefing); end); ok end); end;

20 Shared memory Mutable state is completely unprotected Keyword protected makes object externally uncloneable, immutable Keyword serialized makes object operations externally atomic Modula-3 mutexes, locks, conditions

21 Check list Concurrency: yes Shared memory: yes Parallelism: yes Distributed computation: yes

22 Summary Concurrent resources as channels Copying mutable data probably shouldn’t be implicit (that is so weird) By-reference semantics can extend to distributed setting as network references Not much insight here for dealing with shared memory


Download ppt "Squeak, Newsqueak, Obliq PL Seminar 10/24/2007. Of mice and menus Cardelli and Pike ’85: Squeak: a language for communicating with mice Proof-of-concept."

Similar presentations


Ads by Google