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

Apply doesn't need to check its argument entirely #686

Closed
shirok opened this issue May 3, 2020 · 0 comments
Closed

Apply doesn't need to check its argument entirely #686

shirok opened this issue May 3, 2020 · 0 comments

Comments

@shirok
Copy link
Owner

shirok commented May 3, 2020

If a lazy infinite list is passed to apply, it'll exhaust memory while checking the length of the argument list. But we only need to check up to match the # of required arguments.

Related to #684

@shirok shirok changed the title Apply doesn't need to check it's argument entirely Apply doesn't need to check its argument entirely May 3, 2020
pclouds added a commit to pclouds/Gauche that referenced this issue May 21, 2020
The function check_arglist_tail_for_apply() goes to the end of the list
to determine the length, and whether it's circular. In many cases we
don't really need to know its full length, just whether it's above a
certain limit.

Make the function accept an upper limit and terminate early in these
cases. We could be a bit faster in the pathological case where we know
in advance how many number a procedure may take and we have to handle a
list of a zillion elements.

In one case where we have to unpack the entire argument list, there will
be no upper limit.

This could be the first step to fixing issue shirok#686 too.
shirok pushed a commit that referenced this issue May 21, 2020
The function check_arglist_tail_for_apply() goes to the end of the list
to determine the length, and whether it's circular. In many cases we
don't really need to know its full length, just whether it's above a
certain limit.

Make the function accept an upper limit and terminate early in these
cases. We could be a bit faster in the pathological case where we know
in advance how many number a procedure may take and we have to handle a
list of a zillion elements.

In one case where we have to unpack the entire argument list, there will
be no upper limit.

This could be the first step to fixing issue #686 too.
@shirok shirok closed this as completed Nov 7, 2023
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

1 participant