Skip to content

Literal (string-major) protocols? #94

@LeaVerou

Description

@LeaVerou

Symbols and encouraging symbol-based protocols are a core foundation of this proposal. However:

  • implementors raised concerns that this involves a double lookup
  • other committee members were concerned about ergonomics since the common case is strings

I wonder if a potential way to make everyone happy might be to support defining protocols as either symbol-first (default) or as literal (concept name TBB). A literal protocol would define strings by default, and there would be additional syntax to define symbols. E.g.:

protocol literal P {
	requires foo; // actual string "foo"
	requires symbol bar; // P.bar
	yolo() {} // provides method "yolo"
	symbol quux () {} // provides method P.quux
}

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