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

A way to assign a variable to a field with the same name #1931

Open
norpadon opened this issue May 29, 2024 · 1 comment
Open

A way to assign a variable to a field with the same name #1931

norpadon opened this issue May 29, 2024 · 1 comment

Comments

@norpadon
Copy link

Is your feature request related to a problem? Please describe.
Here is an example config:

let learning_rate = 1e-3
in {
    optimizer = {
        learning_rate = learning_rate
    }
}

If I try to compile it, I get an Error:

error: infinite recursion
  ┌─ /Users/norpadon/Work/ticksim-ml/nuggets/configs/demo.ncl:4:25
  │
4 │         learning_rate = learning_rate
  │                         ^^^^^^^^^^^^^ recursive reference

As I understand, the only way to fix it is to rename the outer learning_rate variable, which is inconvinient.

Describe the solution you'd like
I see two possible solutions:

  1. Introduce some king of special outer record which always contains bindings in the outer scope, so that I can write {learning_rate = outer.learning_rate}
  2. Disabling recursion for quoted field names, e.g. {"learning_rate" = learning_rate}
@yannham
Copy link
Member

yannham commented May 30, 2024

Hi,

This is indeed missing. For the record, I think this is a duplicate of #747, which already has some proposals. But we can maybe keep this issue open as well, because the original one isn't as searchable.

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