Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jpellegrini
Copy link
Contributor

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:

  • Do not store the formal parameters of primitives in their property list, but rather keep them as a string in the structure. Problem: simple, but would be asymmetric (too different from the way it's done for closures).
  • Include the C code to actually set the formals in the property list. Problem: maybe a bit too complex?
  • Do not keep formals for primitives. Problem: well, we won't have formals for primitives :)

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.
@jpellegrini
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant