dlr

DLR and reflection

Everywhere I read about the new DLR in .net 4, they say that a good use for it is reflection, and the code snippet always shown is something like dynamic d = GetSomeObject(); d.DoSomething(); d.SomeMember = 1; What does GetSomeObject() look like? I can't find anywhere that explains that. I understand that it can be anything, but in t...

Is REXX available in .NET?

Is anyone aware of a REXX implementation for .NET? Or plans for one, perhaps using the DLR? ...

Compiling nested mutually recursive function

I'm creating a toy dynamic language (aching towards javascript) and while my implementation is on top of the DLR, I figured the solution to this problem would be pretty language/platform agnostic. I have no problem with compiling recursive functions, or mutually recursive functions that exist next to each other. But compiling nested mut...

.Net 4 DLR - Any books in the pipeline?

I've also been reading through all the documentation about the DLR as this environment is truly exciting for somebody with my kind of tastes! Now - the documentation is quite, well, heavy; even if nice and detailed - and I'm hoping that with such a huge addition to the .Net framework proper (till now it's been a sideline) that somebody ...

Dynamic languages supported by .NET 4.0 DLR

Do you know of the list of dynamic languages that .NET 4.0 DLR supports? I know IronRuby, IronPython are supported. Not sure if IronScheme is. F#? What else? Thanks! ...

Dynamically adding members to a dynamic object

Hi, I'm looking for a way to add members dynamically to an dynamic object. OK, I guess a little clarification is needed... When you do that : dynamic foo = new ExpandoObject(); foo.Bar = 42; The Bar property will be added dynamically at runtime. But the code still refers "statically" to Bar (the name "Bar" is hard-coded)... What if ...

how to declare a byte[] in C# so that ironpython interprets it as byte[] and not as a tuple

In a C++/CLI we have a function that returns this: array^ OutBuffer = gcnew array(BufferSize); IronPython treats it as a byte[]. In C#, we have a funtion that returns this: OutBuffer = new Byte[InBuffer.Length]; While a C# client treats Outbuffer as a byte[], IronPython treats it as a tuple containing multiple arrays. How do we mak...

C# instead of IronRuby as an embedded "scripting" language in .NET 3.5

What is the best practice for using C# as an embedded internal scripting application for a .NET 3.5 application? I have an app with a few small IronRuby scripts in it. None of which is really exploiting the dynamic nature of IronRuby. Apparently its against our corporate standard to be using IronRuby or IronPython right now. Ooopps. Wha...

C# 3.5 DLR Expression.Dynamic Question

I have inherited a small scripting language and I am attempting to port it to the DLR so that it is a little easier to manage. So far it has been fairly straight forward. I have run into a problem though attempting to dynamically call members of a variable. The current language runs on .NET and uses a parsing loop and reflection to do th...

Silverlight DLR: SetVariable("app", this) issue

Hello folks. I have the following code in a Silverlight 3 application using Dynamic Language Runtime JavaScript ("button" is the name of a Button control): private void Button_Click(object sender, RoutedEventArgs e) { var scriptRuntime = ScriptRuntime.Create(); foreach (var name in new[] { "mscorlib", "System", "Sy...

IronPython exposing .Net type to the runtime engine

I'm looking to expose specific .Net types to the IronPython runtime. I can do this: ScriptEngine engine = Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); engine.Runtime.LoadAssembly(typeof(Program).Assembly); // current assembly with types But that exposes all types to the runtime. Is selective type loading possible...

How do you tell if your C# assembly is being called from a ScriptingRuntime?

Supposing I built an assembly with a single class: public class Foo { public void Bar() { // If we're being called from IronPython, IronRuby, etc... do one thing // If not, print some message. Or something. } } Then, from ipy.exe: import clr clr.AddReference('ThatAssembly.dll') from ThatAssemblyName...

IronRuby System.DateTime NilClass

Why comparing to null is so unstable? Just code. IronRuby 0.9.4.0 on .NET 2.0.50727.4927 Copyright (c) Microsoft Corporation. All rights reserved. >>> require 'System' => true >>> i = System::Int32.MinValue => -2147483648 >>> i==nil => false >>> d = System::DateTime.Now => 11.02.2010 14:15:02 >>> d==nil (ir):1: can't convert NilClass ...

.Net 3.5 DLR DynamicObject Help

I have been struggling to get a simple DynamicObject example working in .NET 3.5. Using the latest build of the DLR off codeplex I haven’t been able to figure out what the .NET 3.5 equivalent to the following is: public class DynamicObjectBag : DynamicObject { private Dictionary<string, object> _properties = new Dictionary<string, ...

Running DLR Embedded Scripts in Minimum Security Context

I need to get pointed in the right direction. I have embedded an Iron Python scripting host into a simple C# application, but now I need to know the best practices for locking down security on a user generated IronPython or IronRuby script. Specifically, what are the strategies for preventing library imports and isn't there a way in .NE...

Capturing Standard Output from an IronRuby Script using the DLR APIs

I have a very simple test.rb file: puts "Hello World" I want to execute this file within c#, eg: var runtime = Ruby.CreateRuntime(); runtime.ExecuteFile("C:\test.rb"); How can I capture the "Hello World"? ...

Does the 'dynamic' keyword and the DLR promote C# to a first class citizen as a dynamically typed language?

I understand that the new ‘dynamic’ keyword in C# 4.0 facilitates interaction with dynamic .NET languages, and can help to cut code by using it instead of reflection. So usage is for very specific situations. However, what I would like to know is if it will give C# all the dynamic benefits that one would get in other dynamic languages ...

Ironpython - Named parameters to constructor

When I create an instance of my C# class in IronPython with named parameters to the constructor, it is setting properties corresponding to the names of the parameters. I wish to disable this behavior so I can have better control on the order the properties are evaluated. Is this possible? ...

What is the role/responsibility of a 'shell'?

Hi, I have been looking at the source code of the IronPython project and the Orchard CMS project. IronPython operates with a namespace called Microsoft.Scripting.Hosting.Shell (part of the DLR). The Orchard Project also operates with the concept of a 'shell' indirectly in various interfaces (IShellContainerFactory, IShellSettings). No...

IronPython overriding __setattr__ and __getattr__

I'm trying to implement a class in C# with a method that intercepts the Python __setattr__ and __getattr__ magic methods. I found this bug report: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=8143 But that is from 2008, and nowhere can I find ICustomAttributes or PythonNameAttribute. I don't see anything useful in Int...