It would be nice to annotate global variables and property declarations with a type. (Could annotate --> arrays as well.) Then the compiler could generate warnings (not errors) on object definitions and statically-typable assignments.
This would be entirely opt-in. An unannotated declaration would not be type-checked, which is how Inform works today.
What's a type? At a minimum we need Number, String, Routine, Class, Dictionary, and combined types like String|Routine. Maybe specific object classes too. Can a type include "or zero"? What about "or -1"? (The library defines NULL = -1, and it's a valid value for before.) (In fact the veneer recognizes -1 in such properties.) A list of constant values for an enum?
I am not even getting into the question of how to spell these annotations.
This is difficult but potentially very helpful to authors. Inciting example:
Object obj with article 'the';
(The library wants the article property to contain a string, not a dict word.)
Idea mentioned in forum thread: https://intfiction.org/t/inform-6-compiler-does-not-give-error-when-article-property-uses-single-quotes/55512
It would be nice to annotate global variables and property declarations with a type. (Could annotate
-->arrays as well.) Then the compiler could generate warnings (not errors) on object definitions and statically-typable assignments.This would be entirely opt-in. An unannotated declaration would not be type-checked, which is how Inform works today.
What's a type? At a minimum we need Number, String, Routine, Class, Dictionary, and combined types like String|Routine. Maybe specific object classes too. Can a type include "or zero"? What about "or -1"? (The library defines
NULL = -1, and it's a valid value forbefore.) (In fact the veneer recognizes -1 in such properties.) A list of constant values for an enum?I am not even getting into the question of how to spell these annotations.
This is difficult but potentially very helpful to authors. Inciting example:
(The library wants the
articleproperty to contain a string, not a dict word.)Idea mentioned in forum thread: https://intfiction.org/t/inform-6-compiler-does-not-give-error-when-article-property-uses-single-quotes/55512