Basic Rules

Basic Rules are simple attributes of a design. The rule must return a value of a specific data type, which is included in the declaration of the rule. The long form of a rule specification begins with the Rule keyword and terminates with End Rule .

The following example shows a variation of the same rule, this time using the Return statement to return a value rather than assigning a value to the rule name.

Rule numberOfBearings As Integer
   Return 2
End Rule

The Intent language requires that all local variables be declared with the Dim keyword, as shown in the following example.

Rule totalSprocketWidth As Number
   Dim L As Number = sprocketWidth * numberOfSprockets  

   If isDrive? Then
      totalSprocketWidth = L + driveSprocketSpacerLength _
         - (sprocketHubRecess * 3)
   Else
      totalSprocketWidth = L - (sprocketHubRecess * 2)
   End If
End Rule

Rule Names

The name of a rule must begin with either:

  1. an alphabetic character
  2. an underscore (_)
  3. a percent sign (%)
Note: For more information, click Name link following.

Rule names can contain any number of alphabetic characters, numeric characters, underscores, question marks (?), or percent signs. Intent ignores the case of a rule name. The following names are considered to be the same when evaluated by Intent:

  1. leg
  2. Leg
  3. LEG

Short-Form Rule Specification

The Intent language permits a short-form rule specification for the common “one-liner” rule. This short form can only have an expression (no statements) and must assign a value.

Rule numberOfBearings As Integer = 2

A variant of the short-form rule is the Required rule, which does not have an expression.

Required Rules

A special form of short-form rule uses the keyword Required in place of the rule expression. Required is a keyword that may only appear in this way; it is not a flag. Required rules may only be used in conjunction with the Canonical or Parameter flags. The Required keyword signifies to the compiler that this rule must be supplied (in the case of a Parameter), or that it must be assigned by a Group rule (in the case of a Canonical).

Rule numberOfBearings As Integer = Required
Note: An attempt to evaluate a Required rule will result in a run-time evaluation error when the value has not been supplied as a parameter or cannot be computed via a group rule.