Hacker News new | past | comments | ask | show | jobs | submit login

If I'm understanding your ask correctly, this is basically what implementing Deref in Rust or operator-> in C++ gives you.



Few things that expect a pointer do it by expecting an opaque dereferenceable thing. Most things that expect pointers actually expect a specific concrete pointer type (even if it's a pointer to an opaque thing.)

IMHO, a language with "real suppport" for handles would use them everywhere, instead of pointers—i.e. make all places where pointers pass through "wide enough" for handles to be passed instead—with reduction to a pointer being a kind of WPO for cases where it's proven to be possible.


Implementing `Deref` in Rust implements deref coercions, meaning that it can be used in any function that can accept an appropriate reference.

This is purely syntactic sugar, and no different the compiler inserting `x.deref()` instead of `x` for function arguments. — it's simple q.o.l..


That can give you the syntax! But what I'm curious about is more the implications of actually having this as a part of the language. Does it open up interesting space in optimization or memory safety?


This is a bit like what Regent does. "Pointers" are really offsets into regions, which means that we can transparently move them around a distributed machine on the user's behalf.

http://regent-lang.org/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: