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

[Feature Request]: Allow capturing outer variables in FCFs #26181

Open
alvaradoo opened this issue Oct 31, 2024 · 0 comments
Open

[Feature Request]: Allow capturing outer variables in FCFs #26181

alvaradoo opened this issue Oct 31, 2024 · 0 comments

Comments

@alvaradoo
Copy link

Summary of Feature

Description:
This feature request is to be able to write FCFs that utilize outer variables.

Is this issue currently blocking your progress?
No, my workaround is by including a dummy variable in all of the functions, even though it is not used in 3/4 of them.

Code Sample

I want to be able to write the following code below without the following error being thrown: note: cannot capture proc 'multCriterion' because it refers to outer variables

const m:real = 0.05;

proc log10Criterion(n:int) { return floor(log10(n:real)); }
proc log2Criterion(n:int) { return floor(log2(n:real)); }
proc sqrtCriterion(n:int) { return floor(sqrt(n:real)/5); }
proc multCriterion(n:int) { return floor(m*n:real); }

var criterionFunction = if connectednessCriterion == "log10" then log10Criterion
                        else if connectednessCriterion == "log2" then log2Criterion
                        else if connectednessCriterion == "sqrt" then sqrtCriterion
                        else if connectednessCriterion == "mult" then multCriterion // errors out because `m` is an outer variable
                        else log10Criterion;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants