Dynamic Scope and Context-oriented Programming
or: Raising your Ruby shock-level with ContextR metaprogramming
(What is a shock-level?)
Dynamic Scope
Lexical Scope
History of Dynamic Scope
Semantics of Dynamic Scope
Comparision, side-by-side
Application of Dynamic Scope
STDIN etc.
Environment factors
Dissident
Implementation of Dynamic Scope
really: Dynamic Variables (explain why Scope is not really possible)
Show code!
How to in C (outline only)
Examples
Transition: Dynamically Scoping Methods
Context-oriented Programming
What is it?
What are layers good for?
Decoupling
Separation of concerns
Why?
good question, :-)
Because we can
Cool applications are possible (see later)
Excourse: Basics of method composition
AOP-like "salami tactic"
pre
post
wrap
Example
Example of COP with ContextR
Implementing ContextR
4 hours of hacking
this week :-)
Proof of concept, but no ugly hack
Implementing "salami tactic"
Limitations
&blocks and <1.9
Speed :/
Ideas for the future
Deoptimzation
Compilation
Caching
Hoping that YARV will make it a lot faster ;-)
Surprise, Surprise:
Implementing Namespace Selectors with pure Ruby (!)