hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
720 stars 56 forks source link

Feature request: functions with variable numbers of arguments #194

Open skwerlman opened 10 months ago

skwerlman commented 10 months ago

I'd like to be able to define a function which accepts a variable (within a known range) number of arguments, to be used like this:

foo(1, 2)
foo(1, 2, 3, 4)

I can think of 2 possible ways I might want to be able to define it, default argument values or multiple definitions. For my use case either one will work, though I think multiple definitions is the better one (and it can emulate default values pretty trivially)

; default values
#fn foo(a, b, c=3, d=4) => { ... }

; multiple definitions
#fn foo(a, b) => { ... }
#fn foo(a, b, c, d) => { ... }