[Mono-dev] Functional programming like pure ansi C

Jonathan Pryor jonpryor at vt.edu
Thu Aug 16 06:47:40 EDT 2007


On Thu, 2007-08-16 at 11:38 +0200, Stefan Fink wrote:
> we want to port our own scripting language (only the scripts) to mono (c#).
> 
> 1. Can i call a new Mono programm inside the other one ???

Yes.  See System.Diagnostics.Process.

> 2. include functions from many files ????

No, C# does not support such include functionality.  As an alternative,
you can simply compile the files multiple times, one for each program:

	mcs -o a.exe a.cs c.cs
	mcs -o b.exe b.cs c.cs

In the above, `c.cs' is shared between `a.cs' and `b.cs'.

> 3. call by value or call by reference ????

C# has both pass-by-value and pass-by-reference.  Passing by value is
the default, and by-reference is with the `out' and `ref' keywords:

	class Demo {
		static void Fill (out int a, out string b)
		{
			a = 42;
			b = "hello, world!";
		}

		public static void Main ()
		{
			int c;
			string d;
			Fill (out c, out d);
			Console.WriteLine ("c={0}, d={1}", c, d);
		}
	}

> 4. evaluation at runtime

C# does not have such support.  If you need runtime evaluation, you
could use System.CodeDom (bulky, and probably not quite what you want)
or use another managed language such as JavaScript or Boo.

> 5. embedding mono in c / c++ application and call function from the script to
> the application

Mono can be embedded, and the embedding application can expose "internal
calls" to any managed language.  See:

	http://www.mono-project.com/Embedding_Mono

 - Jon





More information about the Mono-devel-list mailing list