Bash++
Bash++ compiler internal documentation
Public Attributes | List of all members
ContextExpectations Struct Reference

Represents the expectations for the current parsing context. More...

#include <ContextExpectations.h>

Public Attributes

bool can_take_primitive = true
 
bool can_take_object = false
 

Detailed Description

Represents the expectations for the current parsing context.

Copyright (C) 2025 rail5 Bash++: Bash with classes

can_take_primitive: Whether a primitive value is acceptable in the current context can_take_object: Whether a non-primitive object is acceptable in the current context

In the event that a non-primitive object is referenced in a place where only a primitive is acceptable, The Bash++ spec says that the .toPrimitive method should be called automatically.

Further: There are only three cases in which a non-primitive object can be used directly (without conversion to a primitive), And there is only one case in which a primitive cannot be used directly.

The three cases in which a non-primitive object can be used directly are:

  1. In @delete statements
  2. In non-primitive copies (lvalue) [the left-hand side of an assignment, always]
  3. In non-primitive copies (rvalue) [the right-hand side of an assignment iff the left-hand was non-primitive]

The one case in which a primitive cannot be used directly is as the rvalue in a non-primitive assignment. I.e., @nonPrimitiveObject="primitive value"

In all other contexts: primitives are acceptable, and non-primitives are unacceptable.

Member Data Documentation

◆ can_take_object

bool ContextExpectations::can_take_object = false

◆ can_take_primitive

bool ContextExpectations::can_take_primitive = true

The documentation for this struct was generated from the following file: