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

Procedure qualifiers #991

Open
shirok opened this issue Feb 26, 2024 · 3 comments
Open

Procedure qualifiers #991

shirok opened this issue Feb 26, 2024 · 3 comments

Comments

@shirok
Copy link
Owner

shirok commented Feb 26, 2024

define-cproc allows some qualifiers for defined subrs, notably :constant. It sets constant flag of <procedure> and allows the compile to perform constant folding.

We don't have a corresponding mechanism for Scheme-defined procedures.

Syntax-wise, we can allow meta-info between formals and body, e.g. (lambda (x y ..) :constant body ...). How to carry over that information within IForm needs some cleverness. That meta info needs to be saved in the packed IForm.

We have flags slot in $LAMBDA node. It has already been used in non-extensible way. We may change it to contain, say, a list of symbols and/or packed IForm. We still need to recognize the old form, for the precompiled code may contain the old form.

@lassik
Copy link
Contributor

lassik commented Feb 26, 2024

Common Lisp uses

(lambda (x y ...)
  (declare constant)
  ...)

@lassik
Copy link
Contributor

lassik commented Feb 26, 2024

It would be generally useful to have (declare ...) in Scheme eventually, as well as CL style procedure docstrings.

CLHS:

@shirok
Copy link
Owner Author

shirok commented Feb 26, 2024

Good idea. It's flexible.

I do intend, though, to introduce optional type declaration, and although using (declare ...) form is within the boundary of Scheme, I'm inclined to explore syntactic extension to visually indicate it's a meta information.

shirok added a commit that referenced this issue Feb 27, 2024
shirok added a commit that referenced this issue Feb 27, 2024
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

No branches or pull requests

2 participants