|Anonymous | Login | Signup for a new account||2015-04-26 19:15 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0003760||OCaml||OCaml general||public||2005-08-16 21:13||2008-01-25 09:37|
|Target Version||Fixed in Version||3.11+dev|
|Summary||0003760: wish: validation when retrieving public methods|
|Description||Full_Name: Nathaniel Gray|
OS: Mac OS X
Submission from: dhcp-133-195.caltech.edu (220.127.116.11)
The C interface to ocaml offers the caml_get_public_method function for
retrieving a closure by hash from an object's method table. Unfortunately, this
function always returns some method, even if the table doesn't contain the
requested method! It seems caml_get_public_method doesn't check that the hash
you supplied matches the hash it found. It would be nice if either: a)
caml_get_public_method verified that it found the correct method and returned
NULL if it didn't, or b) you provided a separate function
caml_get_valid_public_method that does so.
Why would this be useful? For one, it would make misspelling bugs that are
potentially very difficult to find much easier to find. For another, the
ability to query the method table of an object at runtime could prove handy when
interfacing with dynamic languages. For example, I am currently working on an
OCaml <-> Objective-C bridge. Objective-C method dispatch works by searching
the method tables of each class in the inheritance hierarchy up towards the
root. I would like to be able to create an OCamlProxy object that, when it is
asked to respond to a message, looks in the method table of its OCaml object.
If the method is found then it is used, otherwise the message is passed on to
the superclass. I cannot do this with the current implementation, because
there's no way to learn that an object *doesn't* implement a method.
At the very least, this should be considered a documentation bug. It's
important to know what the failure modes of a function are.
|Tags||No tags attached.|
It looks like I completely forgot this good idea.
This is now done for 3.11: caml_get_public_method returns 0 when the tag was not found.
This does not necesseraly mean that the right method was found (hey, even if the name
was identical, there is no type information available anyway), but at least this is
more elegant than always returning an unrelated method.
|2005-11-18 10:13||administrator||New Issue|
|2008-01-22 17:10||doligez||Relationship added||parent of 0003761|
|2008-01-25 09:37||garrigue||Status||acknowledged => closed|
|2008-01-25 09:37||garrigue||Note Added: 0004437|
|2008-01-25 09:37||garrigue||Resolution||open => fixed|
|2008-01-25 09:37||garrigue||Fixed in Version||=> 3.11+dev|
|Copyright © 2000 - 2011 MantisBT Group|