From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 913357FDF3 for ; Mon, 7 Mar 2016 09:52:44 +0100 (CET) IronPort-PHdr: 9a23:7SuQCRC5INHCbh+eYsglUyQJP3N1i/DPJgcQr6AfoPdwSP7yosbcNUDSrc9gkEXOFd2CrakU1KyG6+u5AD1IyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/niKbio9aKOlQArQH+SI0xBS3+lR/WuMgSjNkqAYcK4TyNnEF1ff9Lz3hjP1OZkkW0zM6x+Jl+73YY4Kp5pIZoGJ/3dKUgTLFeEC9ucyVsvJWq5lH/Sl6t73AFT2gN2jVBGRLE4wz3FsP+uzHgt+Vg1QGfNNH2C7Y9VjOz5uJ2DhbjziUfYW0X6mbS3+N3l71aplq/oBo36ZTZbIyPMP1hNvfSesgFRGwEQINbfzNMCMWwYt1cXKI6Ie9Eotyl9BM1phykCFzpXbu3xw== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=goswin-v-b@web.de; spf=Pass smtp.mailfrom=goswin-v-b@web.de; spf=None smtp.helo=postmaster@mout.web.de Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of goswin-v-b@web.de) identity=pra; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of goswin-v-b@web.de designates 212.227.17.12 as permitted sender) identity=mailfrom; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="goswin-v-b@web.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout.web.de) identity=helo; client-ip=212.227.17.12; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="goswin-v-b@web.de"; x-sender="postmaster@mout.web.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DFAAB3QN1WlgwR49RdDq0uiiGHaoFphgkEAgKBIjoSAQEBAQEBAQEQAQEBAQcNCQkhL4ItghUBAQQ6PxALGAklDwUoIYgfARUEugsfhH8BAQEBAQUBAQEBAQEailSHZYEPBY0wiXqNY4klCoVVRI4RJwqCMxIIFHk8iiYBAQE X-IPAS-Result: A0DFAAB3QN1WlgwR49RdDq0uiiGHaoFphgkEAgKBIjoSAQEBAQEBAQEQAQEBAQcNCQkhL4ItghUBAQQ6PxALGAklDwUoIYgfARUEugsfhH8BAQEBAQUBAQEBAQEailSHZYEPBY0wiXqNY4klCoVVRI4RJwqCMxIIFHk8iiYBAQE X-IronPort-AV: E=Sophos;i="5.22,550,1449529200"; d="scan'208";a="206309009" Received: from mout.web.de ([212.227.17.12]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Mar 2016 09:52:44 +0100 Received: from frosties.localnet ([134.3.242.84]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MY712-1aPdTl3rmK-00Uu4K; Mon, 07 Mar 2016 09:52:42 +0100 Received: from mrvn by frosties.localnet with local (Exim 4.84) (envelope-from ) id 1acqu7-0001Ge-05; Mon, 07 Mar 2016 09:52:39 +0100 Date: Mon, 7 Mar 2016 09:52:38 +0100 From: Goswin von Brederlow To: Jacques Garrigue Cc: OCaml Mailing List Message-ID: <20160307085238.GA4659@frosties> References: <20160307024312.GB31098@frosties> <2D39E7D1-1E36-4481-9195-168184047A51@math.nagoya-u.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2D39E7D1-1E36-4481-9195-168184047A51@math.nagoya-u.ac.jp> User-Agent: Mutt/1.5.23 (2014-03-12) X-Provags-ID: V03:K0:vgry1dJet0laJNnk6iCek0bkWzJAYMQLdJlussSkPmB1lAAui1B CVfBdePYU3BvVVwpCfRuec/+hufgQlCdGaHbYH4VrEtcMjaFdfOzDpwzPfKUt9JnWhjgzih gPjGwxmrzPWOHzXh+Vocw7cGOV6aFZ6dBTQN/stF2g1q/4/yfGUYO58Z3JKcUZ+Cni0FgPp Zx81v8ZjiZ/uqUuqQ/Alg== X-UI-Out-Filterresults: notjunk:1;V01:K0:lp5az944egY=:VCuWsgX0BZSuETZkCszhMg iwuCFMPuzDB/mgtSCCZosbdVmhwx2WgHs0lG7e0wr80SefBjnQELaq56I41vZGZSkoNv2BEUF 2jP3kqv/s5qnEFaQwLLGnMzHFDcmrVRD0n+EXjBGO1uP0Q0D0oJCbtkuDJDwMB39pMOn4V3S2 xwIgmhE89WA5DZ++Otb7MdAGgC5zzeKkWqpafSCSA/4pXpLMH6Ic63RU0XqOTuQUMeYpie5SS tTkDRqbzIdup3YL6SdYkxo9xitOTUsF8XLvgZ3qFDuR441pF5r2Xv348L+wFk3C3fXejjF0VG 8S/2L7LOc6dr2PzHuFBw8zjWJJ//VIgUZLs8jnGoG3MtXYhelzLguu2/5N6452zspG1NNIVbm TbWTFh8WcK6IMaoDpRvHP//FKJ2BZAfzgyfJCb+pDflgrI8bczxPF0LPZxkxkVBJYQ3zLlTwx WRc0QD2B3LWIvGOc98ebbk7M56PUfsV1Gispt+yVs8KngUWrD5J72hkBJ/gzXyr9e5Sa7hRvP tLaZlUUTzVZiOvl2dfbmZfqPJ0rGZUojxJmNB0zfNm4rax4QwTkSQAw+Q5vnk7wmxJXlbC/jg squJ9FJboBYpUf30by4k/25kHsw8un5md7UzTR3w2Y6MJzQe3gWHKxnaLXog2zs/5/v9+UCxE gIm5JQY34shNA805188MhEtwPs7IM5+wZMwXlDUfYWhiYx4SMR0m4Ea8eomdQlPlCH0S7be6s T26e4YmZPw9qnUh4o1xOj6ouA+tcFJ1iH7PleEGEjbtWmboqv4bRxUqIqac= Subject: Re: [Caml-list] How safe is caml_get_public_method() to check if an object has a method? On Mon, Mar 07, 2016 at 02:05:48PM +0900, Jacques Garrigue wrote: > On 2016/03/07 11:43, Goswin von Brederlow wrote: > > > > Hi, > > > > /usr/include/caml/mlvalues.h says: > > > > CAMLextern value caml_get_public_method (value obj, value tag); > > /* Called as: > > caml_callback(caml_get_public_method(obj, caml_hash_variant(name)), obj) */ > > /* caml_get_public_method returns 0 if tag not in the table. > > Note however that tags being hashed, same tag does not necessarily mean > > same method name. */ > > > > In QT5 the classes have virtual methods that can be overloaded. I'm > > considering allowing the ocaml classes to have methods by the same > > name. The C glue would then check if the ocaml class has such a method > > and call it. Otherwise the original method from QT5 would be called. > > > > The question now is wether that is save to do? Is it save as long as > > the names produce unique hash_variant values? Or are the hash tables > > in objects only parts of the bits of the hash_variant and therefore > > collide far more often (given a non-existant method name)? > > > The function used is exactly hash_variant, so if it gives different results on all > your method names, this is safe. > For debugging purposes, I'm also considering adding the method names > as string to the vritual method table. It could help, but you can already extract > all the ocaml method names from your program, and check that there is > no discrepancy. (The probability of having a conflict is very low.) > > Jacques That is good to know. Thx. MfG Goswin