Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

What is the difference between S-attributed and L-attributed definitions ?

AspectS-attributed DefinitionsL-attributed Definitions
Order of attribute evaluationAttributes are calculated as we traverse the parse tree from leaves to root, allowing attributes to depend on children and siblings.Attributes are evaluated in a single pass from root to leaves, with restrictions on which attributes can depend on each other.
Dependency restrictionsNo strict rules on attribute dependencies.Some rules limit where attributes can get their values from, especially for inherited attributes.
Evaluation strategyTypically uses bottom-up evaluation, computing synthesized attributes as we move up the tree.Typically uses top-down evaluation, passing inherited attributes down the tree.
ExampleIn arithmetic expressions, the value of an expression depends on the values of its parts, so it’s S-attributed.In type checking, the type of an expression might depend on its context, so it’s often L-attributed.

Leave a Comment