Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000627OCamlCamlIDLpublic2001-11-12 22:352002-04-22 11:03
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
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
trouble:

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

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
types.

What do you think of this?

Hope to hear from you soon,
Dmitry


TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000079)
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker