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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL 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 DB789BC6B for ; Sat, 1 Dec 2007 21:44:21 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAOZVUUfRVYa4mGdsb2JhbACPSgEBBwIGKw X-IronPort-AV: E=Sophos;i="4.23,238,1194217200"; d="scan'208";a="19883504" Received: from mu-out-0910.google.com ([209.85.134.184]) by mail4-smtp-sop.national.inria.fr with ESMTP; 01 Dec 2007 21:44:20 +0100 Received: by mu-out-0910.google.com with SMTP id i10so107264mue for ; Sat, 01 Dec 2007 12:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=cY+wRSsJgVo+SQ6cvEpTP/DwzZt1O//rzXM36OfGDbc=; b=lVvHKsmm3bZtHqUd3donZRkYnbpaJkfrmmHA3y0aNWvkmzV+hQ179pfb8CJ3/zMU0KOvIfhbQFWM0eyRmG7x80fuUmQQ8vmSWAeayBmHvyrjP6c0QfCP2fqRCrhhyONrYk5BIqVywmQsfywp3MOTc8blaX7RWYiTNIgjWzgbxMg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:subject:from:to:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=hiE66nuLG6RCirK+bQT6UA/2hxqTwzmgZpN8j0OHNWQi2xveLttSgzBpPKLTKrNin7HQx2RZTAfCkU6NBuxT9TpBBbrqeJJUT1vXJdfAZ1K6qULMHN3GBCq51Sb6atXOh4RA3oRDEmBAGsBc/9bY/KF/8DYZKpNc+AaT7xEVESI= Received: by 10.82.167.5 with SMTP id p5mr1803548bue.1196541859240; Sat, 01 Dec 2007 12:44:19 -0800 (PST) Received: from ?192.168.0.10? ( [82.237.227.151]) by mx.google.com with ESMTPS id u9sm3720625muf.2007.12.01.12.44.17 (version=SSLv3 cipher=RC4-MD5); Sat, 01 Dec 2007 12:44:17 -0800 (PST) Subject: Technical question about internal representation of functional values From: Benjamin Canou To: caml-list Content-Type: text/plain Date: Sat, 01 Dec 2007 21:44:21 +0100 Message-Id: <1196541861.28430.9.camel@benjamin-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; ocaml:01 prototyping:01 ocamlopt:01 polymorphic:01 closures:01 closures:01 partial:01 partial:01 marshal:01 marshal:01 benjamin:01 benjamin:01 closure:01 closure:01 behaviour:01 Hi, I have a strange question, for which I have a working but incomplete, low level and implementation dependent answer. Maybe I'm missing a less tricky solution, so I want to ask people who understand the internal behaviour of OCaml better than I do. The context is not really important, but let's say, to simplify, that I want to marshal closures in a controlled way (at source level). Basically, I have a table of registered closures that I want to be able to export. These closures are explicitly declared as marshallable in the source by adding them to the table with a dedicated function. There is no way (as far as I know) to build such a polymorphic table, so I use some "not for the casual user" stuff for prototyping and will rely on externals later. Before calling the standard marshal function, I explore the value, and when I find a closure which is in the table, I replace it with a descriptor block (by using a high block tag unused in my prototype, let's say 240). When I find a closure which is not in the table, I reject the value. This is kind of tricky but works well. Now, I want some support for partial applications of these closures (and marshal the environment along with the descriptor block). Unfortunately, a partial application is not easily detectable. My current implementation only works with ocamlopt, is probably highly platform and version dependent and does not satisfy me at all : I unfold applications of "caml_curryN(_M)?". Another idea I have in mind is to write an assembly function which behaves like the vm's application by extending the closure and detect this function (or maybe this application function exists and is bound to an existing C symbol I can use to set Field(closure, 0) ?). So, is there a cleaner way to recognize partial applications of a specific closure by exploring a value ? Thanks for reading these strange questions and my dirty solutions. Benjamin.