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
Provide %-primitives for operations on raw pointers #7252
Comments
Comment author: @diml dobenour, what operations are you thinking about? If your pointers are represented as [Nativeint.t] values, can't you use functions from the [Nativeint] module? |
Comment author: dobenour I am talking about operations that dereference the pointers. This could be achieved by the following C external (for machine words, with [@@unboxed]):
but that would be very slow for what should be a single instruction. Both versions that require alignment and do not require alignment should be provided. |
Comment author: @xavierleroy The return of PEEK and POKE... (https://en.wikipedia.org/wiki/PEEK_and_POKE) I spent my computing life fleeing away from BASIC, either towards lower-level languages (C, assembly) where low-level stuff can be done properly, or towards higher-level languages (Pascal, Lisp, Caml, Coq) where all that low-level crap disappears. Because of that I feel sad when people insist on doing low-level crap in Caml. |
Comment author: dobenour The popularity of ctypes shows that people want to be able to interface with C using pure OCaml. That means pointers. Furthermore, Jane Street can use this feature (per a GPR), and I am certain that MirageOS can as well. |
Comment author: dobenour Can you explain why low-level work cannot be done in OCaml? C lacks a lot of features that OCaml has. Not all low-level code must run without allocation. |
We have discussed this before and I think it is clear that the proposals in their existing form are unsatisfactory. |
Cross-link: this was proposed (and rejected) in #724. |
Original bug ID: 7252
Reporter: dobenour
Status: acknowledged (set by @damiendoligez on 2016-11-08T10:54:20Z)
Resolution: open
Priority: normal
Severity: feature
Target version: later
Category: standard library
Bug description
I am writing an FFI module for OCaml and have noticed a lack of %-primitives to operate on raw pointers represented as nativeints
The text was updated successfully, but these errors were encountered: