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

Procedure overloading #48

Open
HuseyinSimsek7904 opened this issue Mar 1, 2024 · 1 comment
Open

Procedure overloading #48

HuseyinSimsek7904 opened this issue Mar 1, 2024 · 1 comment
Assignees
Labels
compiler Anything about the compiler enhancement New feature or request high-priority

Comments

@HuseyinSimsek7904
Copy link
Member

Procedure overloading is being able to define multiple procedures with same name but different argument signatures. This feature would make many definitions quite simpler in Corth.

For example:

proc say ptr -> in
  putcs
end

proc say int -> in
  putu
end

These two procedures have the same name but different signatures. This allows the compiler to distinguish them from each other. If the stack has an integer in the local stack, it will understand that the call should be made to the second function.

This however has some limitations for procedures that have different argument signatures but which procedure is wanted to be called can not be decided. For example:

proc say int int -> in
  putu " " putu
end

proc say int -> in
  putu
end

If the stack contains two integers, then it is undecidable which one of these procedures should be called. This means that this should not be allowed by the compiler.

@HuseyinSimsek7904 HuseyinSimsek7904 self-assigned this Mar 1, 2024
@HuseyinSimsek7904 HuseyinSimsek7904 added enhancement New feature or request high-priority compiler Anything about the compiler labels Mar 1, 2024
@Utkub24
Copy link
Collaborator

Utkub24 commented May 18, 2024

If the stack contains two integers, then it is undecidable which one of these procedures should be called. This means that this should not be allowed by the compiler.

This sounds like a problem to be solved rather than an error state 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Anything about the compiler enhancement New feature or request high-priority
Projects
None yet
Development

No branches or pull requests

2 participants