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 560147F164 for ; Mon, 7 Mar 2016 06:05:51 +0100 (CET) IronPort-PHdr: 9a23:gK3XZBXrNUB+88/6PP3KFuzxJzbV8LGtZVwlr6E/grcLSJyIuqrYZh2Et8tkgFKBZ4jH8fUM07OQ6PC/HzxYqsna+Fk5M7VyFDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5K6zPF5LIiIzvjqbpq8KVM10D22H1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu3SNp41Rr1ADTkgL3t9pIiy7UGCHkOz4S4zVX4JkxwAHQ/DpDvgU5v8qC/9qaIp1y6BIszwCK5xUxy94q0tRBK+2wkdMDts0mjck9F9l+p0qQi7phNizsaAb4iPLvtxY671eNoGRSxHV8lWRiUEH8W1ZM0NF7xSbq5js4Dhqg5W/lOFDg62Cbaqk2cQiw== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=garrigue@math.nagoya-u.ac.jp; spf=None smtp.mailfrom=garrigue@math.nagoya-u.ac.jp; spf=None smtp.helo=postmaster@mailhost.math.nagoya-u.ac.jp Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mailhost.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@mailhost.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0CoBACVC91W/wWCBoVdhHm8NoYPAoFdEQEBAQEBAQEBYyeCLYIVAQEEOgYDATUBAQ4LGC5XBog0r2qFLQKGEIQDAQEBAQEBBAEBAQEBAQEBEQEGiAYIgkaEOIMtgQ+NNXOJB41tiSmFUUSOETYsggIaFIFDW4k9AQEB X-IPAS-Result: A0CoBACVC91W/wWCBoVdhHm8NoYPAoFdEQEBAQEBAQEBYyeCLYIVAQEEOgYDATUBAQ4LGC5XBog0r2qFLQKGEIQDAQEBAQEBBAEBAQEBAQEBEQEGiAYIgkaEOIMtgQ+NNXOJB41tiSmFUUSOETYsggIaFIFDW4k9AQEB X-IronPort-AV: E=Sophos;i="5.22,549,1449529200"; d="scan'208";a="206272171" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail2-smtp-roc.national.inria.fr with ESMTP; 07 Mar 2016 06:05:49 +0100 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 6983663C6 for ; Mon, 7 Mar 2016 14:05:46 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (rabbit-172.math.nagoya-u.ac.jp [172.16.254.254]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 154242501; Mon, 7 Mar 2016 14:05:46 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=math.nagoya-u.ac.jp; h= subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=alpha; bh=h1GYSFq02YJySHbhQHlKe26qHHw=; b=H6eHQcKSieGC5SDN3GyiQLgdW+Tk +xQ0pkJOX33N7K61IdJRSV4zjt5DVHBGz+Eq1ONONnkV6GBNvMtLBi5LSAhf/rBa Zwtub94BYaWG5VdCEE5hM9wRECzE4U4bxPI7yAL8kzwt/RiQ5KUhsS54tLXOVkiz tUAbURkXWvdQ9RU= DomainKey-Signature: a=rsa-sha1; h=Received:Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=uAE7gtlRM9ZLQKUkdmxMILxJKGJ/D9PimED8MWKiPuSyHPm9xIIbBrGGlSff/v6jk0Egk7Hy0SK81Wv4DVPdkwvKx8cgoaJHQ6jPvYHMuBEMYPa4EVj301pe4+7ke5ky5nqU3+qqXAAMiWw84gTaAktHGTZvMFZAVLuCHL3fMIw=; c=nofws; d=math.nagoya-u.ac.jp; q=dns; s=alpha Received: from [192.168.11.111] (p1163-ipad29okayamaima.okayama.ocn.ne.jp [60.33.191.163]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTPSA id 3A0CC675C; Mon, 7 Mar 2016 14:04:52 +0900 (JST) Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: text/plain; charset=us-ascii From: Jacques Garrigue In-Reply-To: <20160307024312.GB31098@frosties> Date: Mon, 7 Mar 2016 14:05:48 +0900 Cc: OCaml Mailing List Content-Transfer-Encoding: quoted-printable Message-Id: <2D39E7D1-1E36-4481-9195-168184047A51@math.nagoya-u.ac.jp> References: <20160307024312.GB31098@frosties> To: Goswin von Brederlow X-Mailer: Apple Mail (2.3112) Subject: Re: [Caml-list] How safe is caml_get_public_method() to check if an object has a method? On 2016/03/07 11:43, Goswin von Brederlow wrote: >=20 > Hi, >=20 > /usr/include/caml/mlvalues.h says: >=20 > 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. */ >=20 > 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. >=20 > 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 e= xtract 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