amber-lang / amber

💎 Amber the programming language compiled to bash
https://amber-lang.com
GNU General Public License v3.0
3.8k stars 81 forks source link

[Feature] Make declarations of function to be POSIX compliant #334

Closed Ph0enixKM closed 4 days ago

Ph0enixKM commented 1 month ago

Is your feature request related to a problem? Please describe. Currently functions generated by Amber are only bash compliant. Let's use the POSIX syntax for declaring functions.

Describe the solution you'd like Change from:

function foo() {
    # ...
}

to:

foo() {
    # ...
}

Describe alternatives you've considered N/A

Additional context This problem is related to the milestone to support sh

Mte90 commented 1 month ago

If we implement this we need to add also a flag to Amber to define the bash version to support

Ph0enixKM commented 1 month ago

@Mte90 the POSIX version is supported by Bash and SH. Migrating to the POSIX version will not affect the existing bash compatibility

Mte90 commented 1 month ago

I was trying to understand where in the code write function to remove it but I don't find it https://github.com/amber-lang/amber/blob/042ca2aa6851e0439eb737eeadfd5d48d3f34751/src/modules/function/invocation.rs#L37

Ph0enixKM commented 4 weeks ago

@Mte90 it's right here: https://github.com/amber-lang/amber/blob/2e34e15da2654f57ef17ecef4342b01f1e3ea0b6/src/modules/function/declaration.rs#L257