Lizzie is a dynamically compiled scripting language for .NET, allowing you to incorporate dynamically loaded pieces of code into your C# and F# projects. One of its defining traits, is that, first of all, out of the box, it is literally theoretically impossible to execute malicious code, simply since out of the box, it doesn’t contain a single piece of functionality that changes the state of your computer in any way. If you need such functions, which I assume most would, then creating such functions is as easy as marking your method with an attribute, and making sure it has the correct signature. Below is an example.

using System;
using lizzie; class MainClass
{ [Bind(Name = "write")] object Write(Binder<MainClass> binder, Arguments arguments) { Console.WriteLine(arguments.Get(0)); return null; } public static void Main(string[] args) { // Some inline Lizzie code var code = @" var(@foo, function({ +(bar, ""world"")
}, @bar)) write(foo(""Hello "")) "; // Creating a Lizzie lambda object from the above code, and evaluating it var lambda = LambdaCompiler.Compile<MainClass>(new MainClass(), code); lambda(); // Waiting for user input Console.Read(); }
}

Notice how we "bind" a C# method in the above code to our Lizzie lambda object. This makes the C# method available as a "function" internally within our Lizzie code. This trait allows you to easily extend the language, with whatever domain specific extensions you need to solve your particular problem. This makes the language particularly well suited for "Domain Specific Languages."

Source de l’article sur DZONE

L’assistance proposée par ANKAA PMO

ANKAA PMO présent depuis plus de 20 ans sur le marché des services IT, accompagne les DSI dans leur recherche de compétences pour des besoins de renforts en mode régie ou l’externalisation de projets.
Vous souhaitez plus d’information ? Cliquez ici


0 réponses

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *