Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial protocol syntax. #26

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

sigilante
Copy link
Contributor

@sigilante sigilante commented Jan 14, 2025

Target initial syntax:

protocol Arithmetic {
  func add(#) -> #;
  func sub(#) -> #;
};

object Point: Arithmetic {
  let p:(x:@ y:@);
  func init(q:(x:@ y:@)) -> Point {
    p.x = q.x;
    p.y = q.y;
  }
  func add(q:Point) -> Point {
    Point(((p.x + q.x) (p.y + q.y)))
  };
  func sub(q:Point) -> Point {
    Point(((p.x - q.x) (p.y - q.y)))
  };
};

let origin:Point = (0 0);
let vector:Point = (1 2);

origin.add(vector)

Later on, I want to expand protocol syntax and have notes for that, but first let's get it working.

@sigilante sigilante mentioned this pull request Jan 14, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants