The Avail Programming Language
Mobile Users: Click here to view our text rendering warning.

Semantic Restriction

A single semantic restriction enforces a set of rules regarding the meaningful usage of a method.

A semantic restriction may:

  • strengthen the result type of a message send if the argument types indicate that such strengthening is both possible and warranted
  • reject a message send as illegal if one or more of its arguments are deemed inappropriate based on an assessment of their types
  • encode information about the semantics of an operation in such a way that the compiler can mechanically operate upon it. In a sense, it assists the compiler in leveraging the meaning of an operation.

Grammar: Semantic restriction METHOD_NAME is [ PARAM_TYPE_LIST | ANY_TYPE_CALCULUS_REQUIRED ] : OPTIONAL_TYPE;

See also: An in-depth look at semantic restrictions