From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id BFA0ABBC1 for ; Sat, 29 Mar 2008 15:03:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgECAC7p7UdC+VLid2dsb2JhbACRQgEMBQIFCRSTGYR+ X-IronPort-AV: E=Sophos;i="4.25,574,1199660400"; d="scan'208";a="24337373" Received: from wx-out-0506.google.com ([66.249.82.226]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Mar 2008 15:03:22 +0100 Received: by wx-out-0506.google.com with SMTP id h27so657080wxd.15 for ; Sat, 29 Mar 2008 07:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:reply-to:to:subject:date:user-agent:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; bh=opI9SodA3Jk/KX2BneaGky3jK5GD5PqIghMP0WmdD7k=; b=W8bymrCRwigUZab72o9Lo3i1p3vm0MQla59GROQRLOnOj3U4VmGhS7qR29sLlK2Y2FyY7cRdIwakuH5L7rlDtM4Zq4uv9Rr8a6QHQw/2Ek3qevQ8MlGByUOJgn1tXLhgKkeBnuGK8qWWYU4D7q0oU7p2m87Cy7+wlXDBOocc9lI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=from:reply-to:to:subject:date:user-agent:references:in-reply-to:content-type:content-transfer-encoding:content-disposition:message-id; b=eEPrVwAzL63c38h4N2YSYDRMmp0ka8bmNsUDRrdasVi5YKQJBhslc1A6zcbomy2DRsgkqqzPPoRxsnzQNDd3q9kzV9GQLR0ZJvSUDvy4vPuniQka3Yq0K0JHfuX9DFhjicwtHeRtTT8bM5Ma/SsicRqWptdhGnKmdAq3TntAv/I= Received: by 10.151.155.21 with SMTP id h21mr2331034ybo.98.1206799400886; Sat, 29 Mar 2008 07:03:20 -0700 (PDT) Received: from ?192.168.0.103? ( [24.99.180.210]) by mx.google.com with ESMTPS id a30sm2526724rnb.12.2008.03.29.07.03.19 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 29 Mar 2008 07:03:20 -0700 (PDT) From: Peng Zang Reply-To: peng.zang@gmail.com To: caml-list@yquem.inria.fr, jim.farrand@gmail.com Subject: Re: [Caml-list] The Bridge Pattern in OCaml Date: Sat, 29 Mar 2008 10:03:15 -0400 User-Agent: KMail/1.9.7 References: <4a051d930803190929q60d31012kb6c9d2b03a2d2ca6@mail.gmail.com> <1206706146.47ecdfe275806@webmail.in-berlin.de> In-Reply-To: Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803291003.18808.peng.zang@gmail.com> X-Spam: no; 0.00; ocaml:01 hash:01 bandel:01 in-berlin:01 serialize:01 haskell:01 haskell:01 o'caml:01 o'caml:01 ocaml:01 bytecode:01 bytecode:01 toplevel:01 hashtable:01 pointer:01 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 28 March 2008 08:43:42 am Jim Farrand wrote: > On 28/03/2008, Oliver Bandel wrote: > > Zitat von Michael Wohlwend : > > > > Creating a datastrzucture, while creatzing the functionality. > > And later, when you want to serialize what you have build up, > > write that datastructure, you build by your own, to a file. > > and when rereading it, this means: re-create the functionality from the > > datastructure. > > > > Isn't this, what is looked for, here? > > Yes, this definitely solves the problem and meets the requirements I > specified. > > In Haskell, it would be very neat - define a Monad for composing the > ASTs and then code just like you would any other Haskell program, > you're just using a different Monad from normal. > > In O'Caml, a lot less neat because the user providing the behaviour > suddenly isn't really coding the algorithm in O'Caml, but creating a > data-structure that represents the computation. > > But still, it definitely gets the job done. > Forgive me if I'm missing something here, but couldn't you just use OCaml bytecode? It appears to me that OCaml bytecode is perfect for your purposes. It is, exactly, a serialized format for code. So if your client wants to send you some arbitrary piece of code to run, tell them to compile it down to bytecode, send it over the wire, and then on your end, simply interpret the bytecode. In fact you might be able to get away with just calling the current OCaml bytecode interpreter. Or better yet, your client can just send you the plain ascii of the code and you can use the OCaml toplevel to interpret it. (you may have to send the environment of the piece of code as well, but the environment is simply a big hashtable of (symbol, value) pairs. Well, I say "value" but it may be a pointer to another piece of code or a pointer to a file with some raw data in it.) If you are concerned with speed, you can do JIT compilation of bytecode/source. Peng -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iD8DBQFH7kwmfIRcEFL/JewRAiGiAJ9gDrg09aZNvT8dqfHdOjRqmt++awCfYmQ7 nSniH6930lJytpD6BTcgYyU= =1Oaa -----END PGP SIGNATURE-----