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

Implement Namespaces #129

Open
Alexius-Huang opened this issue Jun 17, 2020 · 0 comments
Open

Implement Namespaces #129

Alexius-Huang opened this issue Jun 17, 2020 · 0 comments

Comments

@Alexius-Huang
Copy link
Owner

What?
Namespaces for storing constants and functions.

Why?
Organizing code.

How?
Sample Wyrd Code

namespace Rectangle
  Num sides = 4
  def area(width: Num, height: Num): Num => width + height
  def circumference(width: Num, height: Num): Num do
    (width + height) * 2
  end
end

Rectangle::sides
Rectangle::area(4, 5)
Rectangle::circumference(4, 5)

Compiled Result

const ns_Rectangle = {
  sides: 4,
  area: function (width, height) {
    return width + height;
  },
  circumference: function (width, height) {
    return (width + height) * 2;
  },
};

ns_Rectangle.sides;
ns_Rectangle.area(4, 5);
ns_Rectangle.circumference(4, 5);

Namespaces currently should only support ConstDeclaration and FunctionDeclaration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant