Skip to content

Optional type annotations #170

@erkyrath

Description

@erkyrath

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions