Skip to content

Add label to AbstractObject #94

Open

Description

@StackEnjoyer

Add an optional name label to the AbstractObject type:

Base behaviour:

label(::AbstractObject) = nothing

label(l::Lens) = l.label 

Activity

  1. added
    enhancement
    good first issue
    on Sep 29, 2026
  2. sameer-dhande commented on Sep 29, 2026

    @sameer-dhande

    Hi @StackEnjoyer , I’d like to work on this issue.

    I’ll add the optional label behavior to AbstractObject as described, with the default implementation returning nothing and the appropriate implementation for Lens.

    I’ll keep the change minimal and add or update tests to verify the expected label behavior before opening the PR.

  3. StackEnjoyer commented on Sep 29, 2026

    @StackEnjoyer
    OwnerAuthor

    Go for it 👍

    Actually, you can introduce a label field for all currently introduced AbstractObjects. The generic behaviour would then be:

    label(o::AbstractObject)::Union{Nothing, String} = o.label

    Add docs to the AbstractObject supertype so that the contract is clear. Users will need a way to pass or mutate labels during or after object creation, so you need to consider that

  4. TacHawkes commented on Sep 30, 2026

    @TacHawkes
    Collaborator

    Proposal after reviewing #95 :

    Store labels in the system, not in the objects.

    Instead of a label field in every AbstractObject (as #94 suggests and PR #95 started), labels and metadata live in the system: System and StaticSystem get a meta::IdDict{Any, Dict{Symbol, Any}} field. Then naming works for every object, including user-defined components, with no change to any component struct or constructor (in line with the extension promise). Labels can be renamed after creation even though the components are immutable structs. And a name is unique where it means something, within one setup. The API: System(["M1" => m1, "BS" => bs, l1]), push!(system, "L2" => l2), label(system, obj), label!(system, obj, "L1") (errors on duplicates), system["BS"], and meta(system, obj) for arbitrary metadata, with the label stored under :name. meta is the only per-system-type method; everything else is built on it. The one drawback is that a standalone object outside a system has no label.

    Rollout: (1) Update #94 with this design and explain why the per-object field was dropped. (2) BMO PR with the verbs, tests (pairs, push!, renaming, duplicate labels, objects not in the system, ObjectGroups, StaticSystem, deepcopy, SubString labels), docstrings and the agent skill update. (3) GUI PR: _label reads label(system, obj), renaming in the GUI calls label!, the labels keyword of live_view is deprecated in favor of this, and code export writes the pair syntax.

  5. sameer-dhande commented on Sep 30, 2026

    @sameer-dhande

    Thanks for the detailed proposal. The system-level metadata approach makes sense, especially since it supports labels for user-defined components without requiring changes to their structs or constructors, and allows labels to be renamed even for immutable objects.

    I'll update #94 to reflect this design and the reasoning for moving labels out of individual objects.

    For the implementation, I'll follow the proposed rollout:

    • add meta::IdDict{Any, Dict{Symbol, Any}} to System and StaticSystem
    • build the label API around meta(system, obj)
    • support labeled construction via pairs, push!, renaming, duplicate-label checks, and lookup
    • cover objects outside the system, ObjectGroups, StaticSystem, deepcopy, and SubString labels
    • add the corresponding docstrings and agent skill updates
    • handle the GUI changes separately as proposed

    For #95, I'll rework the current per-object implementation to follow this design rather than continuing with the Lens field approach.

  6. sameer-dhande commented on Sep 30, 2026

    @sameer-dhande

    Revised implementation approach

    Following the discussion, this issue will be implemented using system-level metadata rather than storing labels directly on AbstractObjects.

    Design

    System and StaticSystem store system-local metadata:

    meta::IdDict{Any, Dict{Symbol, Any}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions