
The challenge of first-class memory - sctb
http://okmij.org/ftp/Computation/types.html#1st-class-memory
======
mratsim
Sounds like memory regions in Nim[1]

    
    
      type
        Memory[T] = object
          len: int
          data: ptr UncheckedArray[T]
      
        Kernel = object
        Userspace = object
      
      
      var a: Kernel ptr Memory[int]
      var b: Userspace ptr Memory[int]
    
    
      a = b # type mismatch: got (ptr[Userspace, Memory[system.int]]) but expected 'ptr[Kernel, Memory[system.int]]'
    

You can even change the GC to region-based memory management [2].

[1]: [https://nim-lang.org/docs/manual.html#types-memory-regions](https://nim-
lang.org/docs/manual.html#types-memory-regions)

[2]: [https://en.m.wikipedia.org/wiki/Region-
based_memory_manageme...](https://en.m.wikipedia.org/wiki/Region-
based_memory_management)

------
juancn
You mean program in C?

