abstract syntax, DLR Expression and, 29
abstract syntax trees (ASTs), 14
Accept method
Expression class, 32
Add method (Expression class), 34
advice, AOP and, 166–171, 174–183
algorithms, Visitor pattern and, 56
AOP (aspect-oriented programming), 11, 165–183
AOP framework, integrating with Spring.NET AOP, 174–183
AopMetaObject class, 171, 172, 173
Apache web server, Silverlight and, 252
AppDomain class, 157
application scripting, 10, 239–250
enabling, 244
arithmetic binary expressions, 34
ASP.NET platforms, 251
aspect-oriented programming. See AOP
Assembly class, 152
assignment expressions, 31
ASTs (abstract syntax trees), 14
Ball World (sample) application, 239–250
architecture of, 241
ball collisions, Farseer Physics engine for detecting, 246–248
object model of, 241
user interface of, 248
base objects, Meta-Object Protocol and, 119
binary expressions, 33
BinaryExpression class, 32, 34
BinaryOperation late-bound operation/action, 97
BinaryOperationBinder class, 99
Bind method
CallSiteBinder class, 71
DynamicMetaObject class, 103, 114
DynamicObject class, 119
canonical, 86
DLR Hosting API and, 139
interoperability protocol and, 102–106
late-bound operations/actions and, 94–100
sharing across call sites, 84–86
BindGetMember method (DynamicMetaObject class), 112
late. See late binding
BoolScript engine (sample), 280–295
executing code and, 294
C#
vs. DLR, 22
IL instructions and, 28
C# (cont.)
language interoperability and, 87–102
Call method (Expression class), 27, 54
call site binders, 50
early binding and, 66
restrictions and, 74
CallSiteBinder class, 68, 71, 105
CallSiteBinderExamples, 69
canonical binders, 86
CanReduce property (Expression class), 32, 54
Chrome web browser, Silverlight and, 252
class definitions, changing, 186–196
ClassMetaObject class, 191–196
generated data access and, 207–210
implementation of, 193
CLOS (Common Lisp Object System), 119
closures, 44
CLR (Common Language Runtime), 13, 28
CLR2 conditional compilation symbol, 71, 76
"code as data," DLR Expression and, 28, 196
code scattering/tangling, as cross-cutting concerned resolved via AOP, 165
code editors, 23
code samples in this book, 4, 9–13
Common Language Runtime (CLR), 13, 28
Common Lisp Object System (CLOS), 119
Common Type System (CTS), 96
compilation flags, 71
metaprogramming and, 185
vs. run time, 14
compile-time binding, 66
CompiledCode class, 137, 150, 157
dynamic languages vs. static languages and, 16
metaprogramming and, 186
CompileSourceCode method, 7
concrete syntax, DLR Expression and, 29
conditional compilation symbol CLR2, 71, 76
conditional expressions, 31
console property, of DLR object, 264
ConsoleHost class, 9
Constant method (Expression class), 34
context-free grammars, 221
Convert late-bound operation/action, 98
ConvertBinder class, 99
CPython, 6
CreateDomain method (AppDomain class), 157
CreateFromConfiguration method (ScriptRuntime class), 140
CreateInstance late-bound operation/action, 98
CreateInstanceBinder class, 99
CreateScriptSourceFromFile method (ScriptEngine class), 150
cross-cutting concerns, resolving via AOP, 165
CTS (Common Type System), 96
curly braces ({ }), 40
binder classes and, 100
Expression class and, 54
"data as code," DLR Expression and, 28, 201
data structures, Visitor pattern and, 56
debuggers, 23
debugging
debug build for, 69
viewing binding rules and, 75–78
Debugging API, 25
DefaultBinder utility class, 106
DeleteIndex late-bound operation/action, 98
DeleteIndexBinder class, 99
DeleteMember late-bound operation/action, 97
DeleteMemberBinder class, 99
Divide method (Expression class), 34
DLR (Dynamic Language Runtime), 3–25
application scripting and, 239–250
vs. C#, 22
Common Type System of, 96
components of, 24
downloading/installing, 5
Hello language illustrating, 6–8, 265–274
LINQ query providers and, 196–201
Visitor pattern of, 57
Ball World sample application and, 242, 245
classes of, 137
Hello console and, 268
Hello language and, 266
vs. JSR 223 API (table), 275
metaprogramming and, 185
Stitch domain-specific language and, 211
ways of using (levels), 137, 139, 143, 150, 154
DlrScript class, 233
dlr-spec-hosting.doc file, 137
domain-specific languages (DSLs), 10, 211
. See also Stitch domain-specific languagedownloads
Apache web server, 252
code samples in this book, 4
DLR, 5
Farseer Physics library, 240
Gestalt components, for Silverlight applications, 254
PowerShell, 214
software components used in this book, 4
Spring.NET AOP, 167
tools, 4
dpier project, 210
DSLs (domain-specific languages), 10, 211
. See also Stitch domain-specific languagedynamic data access, 204
dynamic dispatch. See late binding
dynamic expressions, 49
dynamic keyword (C#), 18
Dynamic Language Runtime. See DLR
application scripting and, 239–250
DLR Hosting API and, 134
support for, .NET vs. Java (table), 275
Dynamic method (Expression class), 51
AOP and, 171–174, 177, 180–183
DLR Hosting API and, 139
interoperability protocol and, 102–106
late-binding logic in, 91, 94, 109–114, 119
late-bound operations/actions and, 94–100
Meta-Object Protocol and, 119
dynamic scoping, 41
DynamicExpression class, 50
DynamicMetaObject class, 91, 103, 111–116
dynamic object late-binding behaviors and, 113
late-binding logic/late-binding result and, 112
properties of, 115
DynamicMetaObjectBinder class, 103
DynamicObject class, 119–122, 125
DynamicObjectExamples, 110
early binding, 66
call sites and, 66
late-binding context and, 80
Eclipse, 218
Element class hierarchy (Visitor pattern), 56
embedding languages, 8
context in script engine and, 287
variable passing and, 149
Execute method (ScriptSource), 8
generated data access and, 207–210
expression abstraction, 53
custom classes and, 54
factory methods and, 34
late binding and, 71
Expression property (DynamicMetaObject class), 115
expression reduction, 53
expression trees, 29, 32, 55–63
expressions, 13, 21, 24, 27–63
binary, 33
compiling/interpreting, 16
dynamic, 49
index, 52
lambda, 44
metaprogramming and, 185
ExpressionVisitor class, 58–62, 200
FallbackGetMember method, 104
Farseer Physics Engine, 10, 246–248
Farseer Physics library, 240, 246
flow control expressions, 36–39
fluent APIs, 10
FxCop, 23
generated data access, 207–210
Gestalt components, for Silverlight applications, 253–257
downloading, 254
Hello console sample application and, 271
Gestalt project, 253
gestaltmedia.js file, 254
GetIndex late-bound operation/action, 97
GetIndexBinder class, 99
GetMember late-bound operation/action, 97, 100, 124
GetMemberBinder class, 99, 103
GetMetaObject method, 111
global scopes, 143
variable passing and, 147
Goto method (Expression class), 48
goto statements (C#), 46
GotoExpression class, 46
guest language
DLR Hosting API and, 133
scripting an object model and, 143
Hello console (sample) application, 268–274
Hello World examples, 6–9, 27–31
hosting programming languages. See DLR Hosting API;
Stitch domain-specific languageHostingExamples, 138
IDE (Integrated Development Environment), 23
IDynamicMetaObjectProvider interface, 111, 121, 140, 171
if statements, 21
if-then-else expressions, 37
IfThenElse factory method (Expression class), 37
IL instructions, 28
IMethodInterceptor interface, 168, 172
index expressions, 52
IndexExpression class, 52
InteropBinderExamples, 87
interoperability protocol, 102–106
interoperability. See language interoperability
intrinsic objects, "just text" approach to Web scripting and, 257
Invoke late-bound operation/action, 97, 124
InvokeBinder class, 99
InvokeMember late-bound operation/action, 97, 124
InvokeMemberBinder class, 99
ipy.exe console application (IronPython), 6, 264
IQueryable interface, 197
IQueryProvider interface, 198
ir.exe command console (IronRuby), 264
IronPython
compilers and, 15
downloading/installing, 5
Hello World sample and, 6
Jython and, 277
language interoperability and, 87–94
IronPython.slvx file, 254, 272
IronRuby
downloading/installing, 5
JRuby and, 276
language interoperability and, 87
Java, dynamic languages and, 275–296
vs. .NET (table), 275
JavaHostingExamples, 276
joint points, AOP and, 166
JRuby, 276
"just text" approach to Web scripting, 251, 256–264
Gestalt components for, 253–257
Hello console sample application and, 271–274
L0 (first-level) cache, 79, 82
L1 (second-level) cache, 79, 83
L2 (third -level) cache, 79, 84
Label method (Expression class), 47
lambda calculus (mathematics theory), 44
lambda expressions, 44
Lambda method (Expression class), 44
language consoles, 264
language consumers, 133, 137, 138
language context, Hello language and, 7
language developers, 138
language interoperability, 25, 87–91
Common Type System and, 96
DLR Hosting API and, 133–136, 139
interoperability protocol for, 102–107
language-neutral scopes, 143, 145, 148
language plug-ins, for non-DLR-based languages, 234–237
language-specific scopes, 143
late binding, 20, 25, 50, 65–86
CallSiteBinder class for, 71
canonical binders and, 86
late-binding context and, 80
late-bound operations/actions and, 94–100
FallbackGetMember method and, 104
in dynamic objects, 91, 94, 109–114
lexer/parser generators, 218
LINQ expressions, 21
LINQ queries, 196
Query class implementation and, 196
Load method (Assembly class), 152
LoopExpression class, 48
MarshalByRefObject class, 157
member method invocation, 94
member property get-access operation, 94
Meta-Object Protocol (MOP), 119
late-binding logic of, 111–114
Meta-Object Protocol and, 119
MetaExamples, 187
methods, adding to/removing from a class, 186–196
Microsoft.Scripting.Ast namespace, 76
Microsoft.Scripting.Hosting namespace, 137
Model-View-ViewModel (MVVM), 241
MOP (Meta-Object Protocol), 119
mscorlib.dll assembly, 67
MVVM pattern, 241
nested scopes, 41
.NET 2.0, 69
.NET 3.5, 69
.NET 4.0, 69
.NET 4.0 SDK, 4
.NET CLR, 154
.NET libraries, 23
NodeType property
BinaryExpression class, 32
ObjectOperations class, 150
documentation string of Python functions obtained via, 156
Python class instances created via, 153
objects meta. See meta-objectsMeta-Object Protocol and, 119
passing by value/by reference, 146–150
Parallel Extensions for .NET, 217, 230
ParameterExpression class, 73
parser generators, 218
path property, of DLR object, 264, 273
PlatformAdaptationLayer class, 154
pointcuts, AOP and, 166–171, 174–183
polymorphic inline caching, 25, 65
PostIncrementAssign method (Expression class), 48
PresentationCore.dll assembly, 152
PresentationFramework.dll assembly, 152
Print helper method, 36, 43, 53
PrintExpression (custom) class, 53, 59–63
production rules, Stitch grammar and, 222
hosting. See DLR Hosting API
language interoperability. See language interoperability
properties, adding to/removing from a class, 186–196
Python
application scripting and, 244
class instances created via ObjectOperations class, 153
functions of, documentation string for obtained via ObjectOperations class, 156
Java and, 276
Stitch language and, 212
Queryable class, 198
Read-Eval-Print-Loop. See REPL console
Reduce method (Expression class), 32, 54
for Hello language, 9
for IronPython, 6
resources for further reading
DLR Hosting API, consumer side of, 137
"just text" approach to Web scripting, 252
restrictions on binding, 74, 80, 113
Restrictions property (DynamicMetaObject class), 115
Return method (Expression class), 72
RIAs (Rich Internet Applications), 251
Ruby
language interoperability and, 87–95
Stitch language and, 212
parts of, 74
vs. compile time, 14
vs. runtime, 14
run-time binding. See late binding
runtime weaving, 170
metaprogramming and, 185
Ball World application, 239–250
CallSiteBinderExamples, 69
DynamicObjectExamples, 110
Hello console application, 268–274
HostingExamples, 138
InteropBinderExamples, 87
late-bound operations/actions, 94
MetaExamples, 187
Stitch domain-specific language, 214–218
SAOs (server-activated objects), 159
script code, Hello language and, 7
script context for, 286
script engine discovery mechanism for, 284
script runners, 226, 228, 231–233
passing objects by value/by reference, 146–150
ScriptEngine class, 8, 135, 150, 157
ScriptHost class, 154
scripting
XAML, 260
loading assemblies via, 152
MarshalByRefObject class and, 157
programming language configuration and, 140–143
script runtimes run in separate process, 159
script runtimes run remotely, 156
scripting an object model via, 143
ScriptScope class, 137, 140, 145
Execute method, 8
MarshalByRefObject class and, 157
semantics, 21
serialization, DLR Expression and, 29
server-activated objects (SAOs), 159
SetIndex late-bound operation/action, 97
SetIndexMember class, 99
SetMember late-bound operation/action, 97
SetMemberBinder class, 99
shape-based design, 32
building DLR source code for, 266
Gestalt components for, 253–257
"just text" approach for, 251, 256–264, 271–274
SimpleLoggingAdvice class, 172
Singleton SAO objects, 159
software components used in this book, downloading, 4
solution files, 69
source language, dynamic objects and, 91
Spring.NET AOP, 167–170, 174–183
statements, DLR Expression and, 29
static data access, 202
static objects, 91
vs. dynamic objects, 109
Stitch domain-specific language, 211–238
DLR Hosting API and, 211
hosting DLR/non-DLR-based languages and, 216
parallel execution of, 217, 230
sequential execution of, 216, 217
DlrScript class and, 233
language plug-ins for, 234–237
script engine and, 227
StitchDemoApplication project, 215, 225
strongly typed languages, 17
switch expressions, 38
Switch factory method (Expression class), 38
SwitchCase factory method (Expression class), 38
SwitchExpression class, 38
System.Core.dll assembly, 69
System.Linq.Expressions namespace, 76
Expression class. See Expression class
IndexExpression class, 52
LoopExpression class, 48
target language
binders and, 92
dynamic objects and, 91
Task Parallel Library (TPL), 230
Text Visualizer tool, 75
time, binding and, 66
ToLower method (String class), 67
TPL (Task Parallel Library), 230
Try methods (DynamicObject class), 119
type checking/type definition, 17–20
Type property
BinaryExpression class, 33
UnaryOperation late-bound operation/action, 97
UnaryOperationBinder class, 99
unit test framework, 23
Update delegate, 79
user interface
for Ball World sample application, 248
for Hello console sample application, 269
variable binders, 50
VB.NET, IL instructions and, 28
Visit method (Visitor class), 57, 59
VisitBinary method (ExpressionVisitor class), 62
VisitChildren method (Expression class), 58
VisitConstant method (ExpressionVisitor class), 61
VisitExtension method (ExpressionVisitor class), 59, 61
Visitor class hierarchy (Visitor pattern), 56
Visitor design pattern, 32, 55–63
Visual Studio, Text Visualizer tool and, 75
Visual Studio 2010 Express, 5
web browsers, Silverlight and, 252
Web platforms, 251
Web scripting
approaches to, 251
web servers, Silverlight and, 252
while loop, 48
while statements (C#), 48
Windows Presentation Foundation (WPF), 144, 240
WPF (Windows Presentation Foundation), 144, 240
WPF assemblies, loading into script runtime and, 152
XAML scripting, 260
18.223.196.146