[Mono-dev] Functional programming like pure ansi C
Marcos Cobeña Morián
marcoscobena at gmail.com
Thu Aug 16 06:41:00 EDT 2007
Hello,
Comments in-line.
2007/8/16, Stefan Fink <sf at granit.de>:
> hallo,
> we want to port our own scripting language (only the scripts) to mono (c#). i
> have a few questions :
>
> 1. Can i call a new Mono programm inside the other one ???
Yes, you can. System.Diagnostics.Process can help you.
> Example.....................
>
> makro1.mak
> --------------------------------------------------
>
> program;
> var
> int ret;
> begin
> ret = MAKROSTART("makro2.mak HALLO");
> print string ("Makro 2 returned : "+ztostr(ret)+"\n");
> end.
>
>
>
> makro2.mak
> ----------------------------------------------------------------------
> program;
> var
> string str;
> begin
> GET_VARTEXT("MAK_PARAM1",*str);
> print string (str+"\n");
> return(1);
> end.
>
>
>
>
> 2. include functions from many files ????
This could be handled manually, if you generate IL from your MAK files
(Mono.Cecil can help you), for instance. You should just reference
your own generated code.
> Exampe........................
>
>
> makro1.mak
> ------------------------------------------------
>
> include("include1.mak");
> include("include2.mak");
> .....
> ....
>
>
> program;
> var
> real val,newval;
> string str,newstr;
> begin
> str = "Hallo";
> newstr = strteil(str,1,2);
> print string (newstr);
>
> val = 0.2;
> newval = arccot(val);
> print string (ztostr(newval));
> end.
>
>
> include1.mak
> ----------------------------------------------
>
> procedure strteil(string str, int pos, int anz);
> var
> string newstr;
> begin
> .....
> newstr = .....;
> ....
> return(newstr);
> end;
>
> .....
>
>
>
> include2.mak
> ---------------------------------------------------------
>
> procedure arccot(real x);
> begin
> return((PI/2)-atan(x));
> end;
>
> .....
>
>
>
> 3. call by value or call by reference ????
Sure, C# has that possibility. But it'd be nice to know if you want to
port MAK files to C# ones, or generate valid IL for .NET/Mono
runtimes. I encourage you to go for this last option, as you can then
consume everything targeting runtime: mscorlib, etc.
>
> Example...............
>
>
> makro1.mak
> -------------------------------------------------------
>
>
> procedure str_para (string s, string para, string trenner);
> var
> int pos,len;
> begin
> len = strlng(trenner);
> pos = strsuch(s,trenner);
> if (pos == 0) then
> pos = strlng(s)+1;
> para = strteil(s,1,pos-1);
> s = strentf(s,1,pos+len-1);
> end;
>
> program;
> var
> string str,para;
> begin
> str = "Hallo,du,Haus,Tanne";
> while (str != "") do
> begin
> str_para(*str,*para,",");
> print string ("Para : "+para+"\n");
> end;
> end.
>
>
> PS: * indicates call by reference -- no * indicates call by value
>
>
>
>
> 4. evaluation at runtime
Again, AFAIK this should be handled manually.
> Example...........
>
>
> program;
> var
> int x,y,z;
> begin
> x = 5;
> y = 6;
> z = berstr("x+y");
> print int (z);
> end.
>
>
> 5. embedding mono in c / c++ application and call function from the script to
> the application
Sure, P/Inovoke will give you this.
>
> Example..........
>
>
> C-Application
> ----------------------------------------
>
> void drawrect(double x1, double y1, double x2, double y2) {
> ...
> }
>
>
> void main() {
> }
>
>
> Mono Script (program)
> --------------------------------------------------
>
> ....
>
> drawrect(1,1,5,5);
> .....
>
>
> --
> Mit freundlichen Grüßen
> Stefan Fink
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
We'll be looking forward to your port. ;-)
My two bits.
Regards,
--
Marcos - http://www.youcannoteatbits.org
More information about the Mono-devel-list
mailing list