Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003760OCamlOCaml generalpublic2005-08-16 21:132008-01-25 09:37
Reporteradministrator 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version3.11+dev 
Summary0003760: wish: validation when retrieving public methods
DescriptionFull_Name: Nathaniel Gray
Version: 3.08.3
OS: Mac OS X
Submission from: dhcp-133-195.caltech.edu (131.215.133.195)


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.

Thanks,
-Nathan Gray

TagsNo tags attached.
Attached Files

- Relationships
parent of 0003761closed Re: [Caml-devel] wish: validation when retrieving public methods (PR#3760) 

-  Notes
(0000270)
administrator (administrator)
2005-08-26 14:19

see PR#3761
(0004437)
garrigue (manager)
2008-01-25 09:37

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.

- Issue History
Date Modified Username Field Change
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
Powered by Mantis Bugtracker