kiedtl / finwe

A concatenative language for the Uxn VM with full compiler-enforced stack safety.
MIT License
35 stars 0 forks source link

Constant-type pointers, readonly ports #6

Open kiedtl opened 8 months ago

kiedtl commented 8 months ago

The idea is that pointers are marked as const using some method, and are then prohibited from being passed to words that (indirectly or directly) call STA (i.e. takes a non-const pointer).

("Marking" pointers in this case means modifying their type signature. I'm not settled on what the signature for this is -- could be @const Type, @@Type, &Type, (Cons @Type), or something else.)

Pointers can be made const in a few ways:

Same principle for device ports -- writing a readonly port literal results in Const_Dev16/Const_Dev8, which cannot be passed to words that require a non-readonly port. (Not sure if adding this particular feature is worth the extra complexity. I mean, how often would one accidentally try to write to a readonly port?)

kiedtl commented 1 month ago

Should probably use different terminology to differentiate from const words, which will be added at some point (to enable compile-time calculations etc).

immut/readonly would be good for this.