Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-work gffi finalization to remove mandatory return value boxing #70

Open
GoogleCodeExporter opened this issue Aug 23, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

GFFI return values are currently boxed to allow a .finalizeWith() method on
all return types, including primitives.

This has caused a host of small bugs because the programmer's mental model
is broken.  It also complicates the ability to finish the removal of
CFunction.call.  Essentially, we are constantly paying the mental/overhead
penalty of boxed types and very rarely seeing the benefit.

Suggest we move away from

var fd = _open.call("filename", O_RDWR);
fd.finalizeWith(_close, fd);

and toward something like

var fd = _open("filename", O_RDWR);
fd = gffi.finalizeWith(fd, _close, fd);

This forces a re-write of fd into a boxed type, insuring that the
programmer knows exactly what's going on -- potentially allowing code like
this:

this.fd = _open("Filename", O_RDWR);
this._fd_gcRoot = gffi.finalizeWith(null, _close, this.fd);

...and perhaps finalizeWith is now less appropriate than, say, "new
gffi.finalizingBox()".

Original issue reported on code.google.com by wes%page...@gtempaccount.com on 4 May 2010 at 3:42

@GoogleCodeExporter
Copy link
Author

Original comment by wes@page.ca on 5 Sep 2012 at 3:23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant