Factor/To do/Static stack safety

  • every word has a stack effect
  • the effect is set at word construction time!
  • stack effect can be unknown: ( ... )
  • effect<= checks for an unknown
  • if word calls words w/ unknown effect, don't compile
  • call of unknown quot from optimized word checks effect
(( ... )) call-with

: foo ( ... q: ( a -- b ) -- ) call ;
  • we don't want to load stack checker in stage1
  • define calls a stack checker hook
  • we no longer need usages xref, "inferred-effect" word-prop, "compiled-effect" word-prop

we can roll this out in phases:

phase 1: require declarations in all contexts and have :, HOOK:, GENERIC:

actually parse the declaration so omitting it is a syntax error

assert-depth should infer

phase 2: introduce ... in stack effects and enforce it

no such thing as an inference warning anymore!

phase 3: define-declared becomes define


  • changing effect of inline ... word may bubble up to callers.
  • we can get rid of ... words altogether if some combinators, such as dip, bi, and so on, become strongly-typed.

This revision created on Wed, 26 Nov 2008 00:31:56 by slava