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

Document DEDORSE #28

Open
sampsyo opened this issue Jul 23, 2014 · 0 comments
Open

Document DEDORSE #28

sampsyo opened this issue Jul 23, 2014 · 0 comments
Labels

Comments

@sampsyo
Copy link
Member

sampsyo commented Jul 23, 2014

We should document our weirdly-named DEDORSE construct, which is a hacky workaround for memory allocation in C.

Here's the deal. In C, a malloc call returns a void*, and then you cast it to the correct type. (This is dumb, what are you gonna do?) This means you want it to sometimes give you a precise pointer and sometimes an approximate pointer. You currently can't do this in the syntax—you can't do (APPROX int *)malloc(...)—so the typechecker special-cases malloc and friends to work correctly whether you use it in a precise or approximate context.

This special-casing obviously does not work if the user writes their own memory allocation wrappers. For this case, we provide a DEDORSE cast that turns a precise pointer into an approximate pointer. It should really only be used for allocation and similar constructs, but it's worth documenting.

@sampsyo sampsyo added the docs label Jul 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant