caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Ocaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] How safe is caml_get_public_method() to check if an object has a method?
Date: Mon, 7 Mar 2016 03:43:13 +0100	[thread overview]
Message-ID: <20160307024312.GB31098@frosties> (raw)

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)?


MfG
	Goswin

             reply	other threads:[~2016-03-07  2:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-07  2:43 Goswin von Brederlow [this message]
2016-03-07  5:05 ` Jacques Garrigue
2016-03-07  8:52   ` Goswin von Brederlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160307024312.GB31098@frosties \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).