Skip to content

Set Literal Syntax (#{...}) for PTC-Lisp #164

@andreasronge

Description

@andreasronge

Set Literal Syntax (#{...}) for PTC-Lisp

Overview

Add Clojure-style #{...} set literal syntax to PTC-Lisp. Sets are currently explicitly not supported (LLMs commonly use this syntax causing parse errors). This epic implements MapSet-based sets with O(1) membership, silent deduplication, and minimal operations.

Specification Documents

Progress

Phase 1: Parser

Phase 2: AST Types

Phase 3: Analyzer

Phase 4: Evaluator

Phase 5: Runtime (Critical - MapSet/is_map fix)

Phase 6: Formatter

Phase 7: Documentation

Phase 8: Tests

Notes

Critical regression risk in Phase 5: MapSet is a struct, so is_map(%MapSet{}) returns true. All functions with when is_map(coll) guards will incorrectly match MapSet and crash (expecting {k, v} tuples). Must add explicit %MapSet{} clauses BEFORE generic is_map clauses.

Design decisions:

  • Silent deduplication (#{1 1 2}#{1 2}) for LLM-friendliness
  • coll? returns false for sets (separate set? predicate)
  • Collection ops (map, filter, remove) return vectors, not sets

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:epicEpic issue (contains task list for PM)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions