Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

Browse thread
Meta-programming?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-23 (22:57)
From: Mattias Waldau <mattias.waldau@a...>
Subject: RE: "ocaml_beginners"::[] Re: Meta-programming?
Dynamic Caml v.0.2 is also a possible solution.

http://oops.tercom.ru/dml/

Dynamic Caml is a high-level, type-safe (statically typed)
and efficient dynamic code generation library and a set of 
CamlP4 syntax extensions for Objective Caml. 

> -----Original Message-----
> From: felixgrupp [mailto:felixprog@h...] 
> Sent: Wednesday, May 15, 2002 2:49 PM
> To: ocaml_beginners@yahoogroups.com
> Subject: "ocaml_beginners"::[] Re: Meta-programming?
> 
> 
> This is the problem with static languages. In Lisp, for example, it 
> is easy to take a string and execute it as code, but in OCaml, the 
> compiler won´t compile your code unless the type of every identifier 
> is known. This way, it is guaranteed that the program will never try 
> to do anything illegal, such as trying to multiply two strings.
> 
> If it were possible to read code from a file and execute it, there 
> would be no way for the compiler to know what kind function calls the 
> program would try to do, and so could not guarantee the safety of the 
> program. A lot of other problems would appear too. For example, the 
> code read from the file might contain declarations or function calls 
> that influences the rest of the program (after the contents of the 
> file had been executed), making it impossible for the compiler to 
> know very much at all about how to compile the program. It would have 
> to include a version of it self and parser et cetera, and also all 
> the library files... On top of witch, the program would also run very 
> much slower because it would have to do a lot of type checking and 
> other stuff at run time, wich otherwise the compiler takes care of. 
> 
> All of this explains why one would like to use a static programming 
> language: safety, speed and (to a lesser degree) size of the compiled 
> code.
> 
> So, what you have to do is write a small parser yourself (preferably 
> using the OCaml library) and an interpreter implementing what ever 
> functionality you need. This is a typical example of what advocates 
> of dynamic languages are always claiming: any interesting program 
> will end up implementing a new (small or large) language.
> 
> 
> You might want to check out MetaOCaml at
> 
> http://cs-www.cs.yale.edu/homes/taha/MetaOCaml
> 
> They use a model called staged computation, which seems to be a lot 
> more disciplined than eg Lisp. I am rather curious myself about what 
> can be done in it.
> 
> /Felix
> 
> --- In ocaml_beginners@y..., stalkern2 <stalkern2@t...> wrote:
> > Hello to everybody I'm wondering whether in Ocaml one can roll up a
> > string:string and then use a command that takes that string as a 
> command, 
> > something like: interpret_this = fun s:string -> commands. 
> Actually, 
> > I'm using configuration files where everything is a
> string, and I'd 
> > like to turn them into initializations for a program. If I had only
> a few  
> > initializations, I could manage them one by one, but when they are
> many, I'd 
> > rather have a program reading them. The point is, in a
> configuration file the 
> > name of a variable is a "name", i.e. a string. Well, I can't say in
> my 
> > program 
> > let "varName" = value,
> > I have to say 
> > let varName = value.
> > 
> > So I thought that maybe it is possible to say 
> > some_meta-command "let varName = value".
> > 
> > Any idea?
> > 
> > Thanks
> > Ernesto
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> ---------------------~-->
> Save 30% on Web addresses! Get with the times, get a web 
> site. Share information, pictures, your hobby, or start a 
> business. Great names are still available- get yours before 
> someone else does!
> http://us.click.yahoo.com/yu.vPA/nFGEAA/sXBHAA/saFolB/TM
> --------------------------------------------------------------
> -------~->
> 
> To unsubscribe from this group, send an email to:
> ocaml_beginners-unsubscribe@yahoogroups.com
> 
> The archives of the very official ocaml list (the seniors' 
> one) can be found at http://caml.inria.fr
> 
> Attachments are banned and you're asked to be polite, avoid 
> flames etc. etc.  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
>