Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[Feature] Make declarations of function to be POSIX compliant

Open Ph0enixKM opened this issue 1 year ago • 4 comments

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

Ph0enixKM avatar Jul 22 '24 19:07 Ph0enixKM

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

Mte90 avatar Jul 23 '24 08:07 Mte90

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

Ph0enixKM avatar Jul 23 '24 09:07 Ph0enixKM

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

Mte90 avatar Jul 31 '24 08:07 Mte90

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

Ph0enixKM avatar Aug 08 '24 16:08 Ph0enixKM