Open kiedtl opened 8 months 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.
(immutify)
(immutify foo)
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) callSTA
(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:
(const)
to constify the pointer on TOS(const foo)
to constify a variable#const (let CONSTANT [ 0x0 ])
to declare a variable constant.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?)