egallesio / STklos

STklos Scheme
http://stklos.net
GNU General Public License v2.0
67 stars 17 forks source link

Add `--without-keep-formals` option to configure #635

Open jpellegrini opened 1 month ago

jpellegrini commented 1 month ago

Hi @egallesio ! This PR partially addresses issue #260 . It adds optional formal parameter information for closures in core STklos and provided libraries -- but not for primitive procedures.

Description

This adds a new option ot the configure script.

If the user passes --without-keep-formals to configure, then the compiler keep-formals parameter will be true when compiling closures in core STklos and all provided libraries.

However, this does not affect primitive procedures, because they are C functions, and having the C compiler include the code to add the formal parameters is, although possible... Tricky, at least.

How it works:

We have three autoconf variables:

    STR_KEEP_FORMALS="no"    # for output at the end of this script
    KEEP_FORMALS=0           # for tmpcomp (and in the future, C files)
    SCM_BOOT_KEEP_FORMALS="" # for the Makefile compiling the boot image

The tmpcomp file needs to be called in the Makefiles with the shell variable

KEEP_FORMALS set:
KEEP_FORMALS=@KEEP_FORMALS@ tmpcomp ...

For the boot image, the variable SCM_BOOT_KEEP_FORMALS is directly used.

And... Well, autotools is reeeeeally not something I ever got to understand well, so perhaps there are better ways to achieve what I did.

Future work (primitive procedures)

Since primitives are defined as C functions, this becomes tricky.

The options I thought:

jpellegrini commented 1 month ago

Forgot to mention: the idea is to have formal parameters included by default, but allow the user to not have them for embedded systems or whatever, where size could be an issue.

jpellegrini commented 1 month ago

The --without-keep-formals name means "without the compiler flag keep-formals", but it sounds a bit strange. Maybe we could change that to --without-formal-arguments? I don't know.