You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
(const) to constify the pointer on TOS
(const foo) to constify a variable
#const (let CONSTANT [ 0x0 ]) to declare a variable constant.
Not a fan of this one, as it encourages abusing variables to hold constant values (words should be used for that).
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?)
The text was updated successfully, but these errors were encountered:
Should probably use different terminology to differentiate from const words, which will be added at some point (to enable compile-time calculations etc).
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?)The text was updated successfully, but these errors were encountered: