Why do you want the code to be illegal? I can imagine use cases where something 
like that is exactly what you want. I do agree that this is a bit ugly. And how 
far do you want to go? Since cstring is a pointer type, should this be illegal, 
too?:
    
    
    var heap: ptr int
    
    proc intPtrEscapes(ip: ptr int) =
      heap = ip
    
    var i = 123
    intPtrEscapes(ip.addr)
    

If you **really** want to prevent **all** dangerous usages, you can restrict 
cstring to be allowed as parameters for procedures. Then you can be sure when 
someone want's to keep a value of a cstring somewhere he needs to call `$` or 
something similar to copy the value.

But isn't cstring the type you mostly need for writing wrappers? The code where 
you are often forced to do some "unsafe" operations in order to get it running? 

Reply via email to