Declarative Objects - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Declarative Objects

Description:

Declarative Objects 7/22/10 Jonathan Edwards sdg csail MIT – PowerPoint PPT presentation

Number of Views:75
Avg rating:3.0/5.0
Slides: 49
Provided by: JonathanE155
Category:

less

Transcript and Presenter's Notes

Title: Declarative Objects


1
Declarative Objects
  • 7/22/10
  • Jonathan Edwards
  • sdg csail MIT

2
CMP AX,BX JE SKIP MOV AX,2
3
class Task int start int end
4
class Task int start int end int length
get return end - start set end
start value
5
class Task int start int end int length
get return end - start set end
start value // start after t, increment
length void slipAfter(Task t)
6
class Task int start int end int length
get return end - start set end
start value // start after t, increment
length void slipAfter(Task t) start
t.end length length 1
7
class Task int start int end int length
get return end - start set end
start value // start after t, increment
length void slipAfter(Task t) start
t.end length length 1
?
8
class Task int start int end int length
get return end - start set end
start value // start after t, increment
length void slipAfter(Task t) length
length 1 start t.end
?
9
class Task int start int end int length
get return end - start set end
start value // start after t, increment
length void slipAfter(Task t) int
oldLength length start t.end length
oldLength 1
10
class Task int start get return end -
length set end value length
int end int length // start after t,
increment length void slipAfter(Task t)
length length 1 start t.end
11
?
class Task int start int end int length
get return end - start set end
start value void slipAfter(Task t)
int oldLength length start t.end
length oldLength 1
12
!
Pac-Man
13
t
start
end
length
3
this
this
start
start
end

get
end

set
length
1
length
1
2
4
pre-state
post-state
14
Task obj start int end int
length end start length trig
end lt start length slipAfter act
t Task start lt t.end length
lt \length 1
15
definition
Task obj start int end int
length end start length trig
end lt start length slipAfter act
t Task start lt t.end length
lt \length 1
data binding (getter)
triggered action (setter)
assignment
called action (method)
pre-state
16
Task obj start int end int
length end start length trig
end lt start length slipAfter act
t Task start lt t.end length
lt \length 1
1 4 3 2
17
  1. \length end start
  2. length \length 1
  3. start t.end
  4. end start length

Compiler
18
Declarative Programming
what
how
Compiler
19
Parallel Processing
what
how
Compiler
20
Distributed Processing
what
how
Compiler
21
Pointers
22
t
start
end
length
this
this
start
start
end

get
end

set
length
1
length
pre-state
post-state
23
t
start
end
length
t this
this
this
start
start
end

get
end

set
length
1
length
pre-state
post-state
24
t
start
end
length
t this
this
this
start
start
end

get
end

set
length
1
length
pre-state
post-state
25
pointers ? undecidable dataflow
Huh?
Compiler
26
Pick two
?
Declarative programming
Circuits
Functions
?
?
Data structures
Mutable state
Imperative programming
27
Nesting Binding
Model-View dataflow
28
Task
start
Project
Project obj task1 Task task2 Task
end
task1
length
task2
Task
start
end
length
29
Project
task1
start
Project obj task1 Task task2 Task
end
length
task2
start
end
length
30
Project
task1
start
Project obj task1 Task task2 Task
task2.start gt task1.end
end
length
task2
start
end
length
bidirectional binding
31
tasks
tasks dom Task
_at_3F25C
start
end
length
_at_5E820
start
end
length
32
quantified binding
cursor
tasks
tasks dom Task task1 ?gt tasks
task1
start
_at_3F25C
end
start
length
end
length
_at_5E820
start
end
length
33
tasks
tasks dom Task task1 ?gt tasks task2 ?gt tasks
task1
start
_at_3F25C
end
start
length
end
length
_at_5E820
task2
start
start
end
end
length
length
34
tasks
tasks dom Task task1 ?gt tasks task2 ?gt
tasks task2.slipAfter(task1)
task1
start
_at_3F25C
end
start
length
end
length
_at_5E820
task2
start
start
end

end
length
length
35
tasks
tasks dom Task task1 ?gt tasks task2 ?gt
tasks task2.slipAfter(task1)
task1
start
_at_3F25C
end
start
length
end
?
length
_at_5E820
task2
start
start
end

end
length
length
36
task1
task1
start
start
end
end
length
length
_at_5E820
_at_5E820
task2
task2
start
start
start
start
end
end
end

end
length
length
length
length
37
DB
query
update
Model
get
set
View
output
input
User
38
Model-View dataflow
internal state
  • outputs
  • getters
  • queries
  • inputs
  • setters
  • triggers

external world
39
Model-View dataflow
internal state
  • outputs
  • getters
  • queries
  • inputs
  • setters
  • triggers

?
external world
40
Model-View dataflow
internal state
  • functional
  • lazy
  • mutating
  • eager

external world
41
Model-View dataflow
internal state
  • functional
  • lazy
  • mutating
  • eager
  • callbacks
  • events

?
?
external world
42
New rules, new patterns
  • Synchronous reactive programming
  • Input event triggers atomic state transition
  • Output is pure function of new state
  • Asynchronicity layered on top
  • Syntax order irrelevant no control flow
  • Pre-state readable throughout transition
  • Fields can change once per transition
  • Actions cant see effects of own changes

43
Progression
prog t gt task1 t.slipAfter(task2)
step \t.end ?gtr 10 t.end lt 10
progressive binding
step
result of prev step
guard
step
44
task2
start
end
length
?
?
prog
task1
task1
t
t
?
start
start
start
start
end
end
end
end

gtr 10
10
length
length
length
length
1
?
?
pre-state
post-state
45
task2
start
end
length
hyp
?
task1
task1
t
t
?
start
start
start
start
end
end
end
end

gtr 10
10
length
length
length
length
1
pre-state
post-state
46
Technical Summary
  • Nesting gives objects a location in global tree
  • Bindings propagate changes through relative paths
    in tree (precise static effects)
  • Bindings are directed input, output, or both
  • Input is change-driven, cascades eagerly
  • Output is lazy pure functional
  • Each is statically acyclic based on tree path
    effects
  • Outputs do not feedback to inputs
  • Imperative islands in a declarative sea

47
Pick two
Declarative programming
Data structures
Mutable state
48
Declarative Objects
Declarative programming
Nesting Binding
Model-View dataflow
49
Imperative Programming
Declarative Programming
CMP AX,BX JE SKIP MOV AX,2
Write a Comment
User Comments (0)
About PowerShow.com