Skip to content

add static interfaces in the form of signature types#1543

Draft
zerbina wants to merge 1 commit intonim-works:develfrom
zerbina:signature-types
Draft

add static interfaces in the form of signature types#1543
zerbina wants to merge 1 commit intonim-works:develfrom
zerbina:signature-types

Conversation

@zerbina
Copy link
Copy Markdown
Collaborator

@zerbina zerbina commented May 11, 2025

Signature types are meant to provide static interfaces, which would be a first step towards type-checked generic routines and (maybe) eventually removing .borrow.

The name signature is a working title. It's not yet clear whether the feature will take over concept or stay as its own entity, and thus the concept syntax is simply reused.

The current specification is not meant to represent the final form. It's a version of the feature as discussed so far that's narrowed-down as much as possible in order to make a robust implementation feasible/possible with the current compiler. Further restrictions due to issues discovered during implementation are likely.

The feature was inspired by the signature feature of Standard ML.


To-Do

  • add a signature pragma
  • add dedicated TType kinds for signature types and their applied form
  • implement signature body analysis
  • implement argument-dependent lookup (for signature types)
  • implement signature application (will be based on the existing borrow mechanism, most likely)
  • add tests
  • write a proper commit message

@zerbina zerbina added enhancement New feature or request language-design Language design syntax, semantics, types, statics and dynamics. labels May 11, 2025
Comment thread doc/manual.rst
and `macro`:idx: are not.

For every routine declaration in the body, at least one parameter must be of
type `placholder`, `var placeholder`, or `sink placeholder`. Declarations must
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placholder -> placeholder

Comment thread doc/manual.rst
or more candidates that satisfy the requirements listed above, application
fails. If sucessful, the resulting application is said to *bind* to `y`.

Two applied signatures are equal are equal iff both are applications of the
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iff -> if

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spelling is deliberate. "iff" is a short form of "if and only if" (source).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's not shorter if you have to provide this message along with all reading material 😛

Copy link
Copy Markdown
Collaborator Author

@zerbina zerbina May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, iff is already used in other places of the manual.

Nonetheless, you're right in that the usage does make the text less accessible; I'll expand it.

Comment thread doc/manual.rst
On application of `S` to `T`, for every routine declaration `x` of `S`, a
routine `y` must be *visible* in the current context such that:
* `x` and `y` have the same name
* after all `placholder`s in the parameter list of `x` are replaced with `T`,
Copy link
Copy Markdown
Contributor

@beef331 beef331 May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placholder -> placeholder

@zerbina zerbina changed the title add static interface in the form of signature types add static interfaces in the form of signature types May 25, 2025
@zerbina zerbina mentioned this pull request May 27, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request language-design Language design syntax, semantics, types, statics and dynamics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants