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 __call metamethod support #256

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

codehz
Copy link

@codehz codehz commented Apr 9, 2024

WARNING: Please, read this note carefully before submitting a new pull request:

Nelua is open source,
but not very open to contributions in the form of pull requests,
if you would like something fixed or implemented in the core language
try first submitting a bug report or opening a discussion instead of doing a PR.
The authors prefer it this way, so that the ideal solution is always provided,
without unwanted consequences on the project, thus keeping the quality of the software.

If you insist doing a PR, typically for a small bug fix, then follow these guidelines:

  • Make sure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
  • Don't send big pull requests (lots of changes), they are difficult to review. It's better to send small pull requests, one at a time.
  • Use different pull requests for different issues, each pull request should only address one issue.
  • When fixing a bug or adding a feature add tests related to your changes to assure the changes will always work as intended in the future and also to cover new lines added.
  • Verify that changes don't break the tests, you can check this with make test.
  • Follow the same coding style rules as the code base.
  • Pull requests just doing style changes are not welcome, a PR must address a real issue.

Motivation

Add basic __call metamethod support to nelua, align to lua's behavior

Code example

local Test = @record{value: number}

function Test:__call(a: number): number
  print "test"
  print(a)
  print(self)
  return self.value + a
end

local test: Test = {1}

-- test:__call(2)
test(2)

@codehz codehz requested a review from edubart as a code owner April 9, 2024 15:19
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.

None yet

1 participant