Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000627OCaml-for CamlIDL use 22:352002-04-22 11:03
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000627: Camlidl: what about finalizers for abstract types?
DescriptionOK, I have realized how errorcheck(fn) attribute works for abstract
types. But now there is another crazy idea :-)

Suppose I have the following .IDL definition

typedef [abstract] void* TYPE;
TYPE create_object();
void process_object( TYPE t );
void delete_object( TYPE t );

create_object() allocates some memory and other resources that should be
freed when the object is no longer needed. This job is done by
delete_object(), which should be explicitly called. If not, we are in

let obj = create_object () in
  process_object obj;
  (* no delete_object -- object is not destructed properly! *)

What I propose:

Let's allow optional "fn" parameter to "abstract" attribute, that will
specify finalizer function:

typedef [abstract(delete_object)] void* TYPE;
TYPE create_object();
void process_object( TYPE t );

finaliser function should have type "void fn(TYPE)"

Having such attribute, camlidl allocates custom block with the appropriate
finalizer, that will be called when the block (i.e. object) is
garbage-collected. So abstract camlidl types will be safe as any OCaml

What do you think of this?

Hope to hear from you soon,

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
administrator (administrator)
2002-04-22 11:03

Implemented 2002-04-19 by XL

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2017-02-16 14:37 xleroy Category CamlIDL => for CamlIDL use [^]
2017-02-23 16:43 doligez Category for CamlIDL use [^] => -for CamlIDL use [^]

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker