Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 393
    • Issues 393
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Concepts
  • Overloading

Overloading · Changes

Page history
Make overloading concept file name upper case and change mark to annotate in safe functions idea authored Feb 07, 2025 by Quinten Cabo's avatar Quinten Cabo
Hide whitespace changes
Inline Side-by-side
concepts/Overloading.md 0 → 100644
View page @ 53f9df0a
In SAC, you can overload functions like this:
```c
use StdIO: all;
void foo(int a) { printf("Called foo with int\n"); return;}
void foo(bool a) { printf("Called foo with bool \n"); }
void foo(int[+] a) { printf("Called foo with int[+]\n"); }
void foo(int[3] a) { printf("Called foo with int[3]\n"); }
int main() {
foo(1);
foo(true);
foo([1]);
foo([1,2,3]);
return 0;
}
```
This program should output:
```
Called foo with int
Called foo with bool
Called foo with int[+]
Called foo with int[3]
```
\ No newline at end of file
Clone repository
  • concepts
    • Deprecated Modules
    • Globals
    • Named Tuples
    • Overloading
    • Preprocessor
    • Primitive functions
    • Runetime Representations
    • input stdin
    • phm xt
    • ref counting methods
    • type famlies
    • type patterns
  • error messages
    • Anthropomorphic error essages
    • Colored error messages
    • Empty file error
View All Pages