Skip to content

Resolve = overloading: assignment vs equality #120

@danieljohnmorris

Description

@danieljohnmorris

Problem

= means two different things depending on context:

x=5        -- assignment
=x 5 "yes" -- equality guard (if x equals 5, return "yes")

This is a known source of confusion. The parser disambiguates by position (start of statement + followed by = = assignment), but for humans and AI agents reading the code, the dual meaning adds cognitive load.

Options

1. Keep as-is

  • = for both assignment and equality
  • Minimal tokens — one character serves two purposes
  • Parser handles it fine, but humans may stumble
  • Hints system already suggests ===

2. Use == for equality, = for assignment only

  • x=5 assignment, ==x 5 "yes" equality guard
  • Familiar to most programmers (JS, Python, C)
  • Costs one extra token per equality check
  • Removes ambiguity completely

3. Support both = and == for equality (current state)

  • == already works as a hint that gets normalized to =
  • But having both means two ways to write the same thing
  • Violates one-way-to-do-it principle

Context

Currently == is accepted and hints to =. This works but creates the "two syntaxes" problem. The question is whether the token savings of single = for equality justify the confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions