emdash / udlang

A practical, functional language for stream processing.
GNU Lesser General Public License v3.0
1 stars 0 forks source link

Concept: resource tracking with linear types #14

Open emdash opened 3 years ago

emdash commented 3 years ago

This goes into the "hairbrained ideas" bucket, for post-post-post MVP fun.

We should investigate allowing uDLang to manage opaque pointers to stateful resources by wrapping them in a linear type. This would only make sense in certain embedding contexts, but could be very useful in those cases. Even then, it's a feature which needs some careful thought.

But the general idea is that it's not a problem for uDLang to track, for example, a shared memory handle or other resource, so long as it doesn't touch it directly, and doesn't allow it to be "duplicated" (i.e. unintentionally shared), or "leaked", (i.e. prevents it from being released).

Linear / affine types model the property of "unique" values which flow through the program, entering and exiting in a well-defined fashion. This would allow for straight-forward resource management at the protocol boundary.

The primary use-case I can imagine for this is in the context of, for example, a wayland client. We might want to be able to pass wayland buffers through uDLang, possibly tagging them with useful information in the process. Another use-case might be a uDLang plugin for the GStreamer or puredata. Perhaps also useful with server-side computation.

It's a bit outside the scope of uDLang's primary mission, but it might make for an interesting Summer of Code project.