Dynamic

From The Oxygene Language Wiki
Jump to: navigation, search

This is a Language topic about Oxygene
 

Language Topics Introduction | Structured Overview | Grammar | Keywords | Functions



Dynamic is a new special type introduced with .NET 4 that acts like a variant type. Any calls to a method or class with a dynamic as a parameter will resolve the member and overload at runtime instead of compile time. This is based on the DLR logic and can be used to talk to dynamic languages based on the DLR.

Details

A dynamic is actually a plain System.Object that's treated specially. When used in results and parameters, an attribute is applied to the target. All calls run through call-sites and are generated once per type that is passed to the target.

method Add(left, right: Dynamic): Dynamic;
begin
  exit left + right;
end;


begin
  Add(15, 2); // returns an integer 17 as a dynamic
  Add(false, true); // fails at runtime as true and false cannot be added to each other
end;

Dependency on RemObjects.Oxgene.Dynamic.dll

The current implementation depends on a custom (and freely deployable) dll called RemObjects.Oxygene.Dynamic.dll. This library is used to have the Oxygene compiler behavior for overload resolving, binary operators, unary operators and conversions at runtime. This library does need to be deployed, if this feature is used. Custom implementations can be written by matching the OxygeneBinder, OxygeneArgumentMode, OxygeneArgument and OxygeneBinderFlags types. (Only the public members). This library is a proper implementation so it supports all Oxygene semantics, including case-insensitive checks.

Personal tools
Namespaces

Variants
Actions
Navigation
Getting Started
Sections
If you know
More
Toolbox