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

Storing and dereferencing object references in variables #961

Open
MogaSystems opened this issue Feb 29, 2024 · 3 comments
Open

Storing and dereferencing object references in variables #961

MogaSystems opened this issue Feb 29, 2024 · 3 comments
Assignees
Labels
enhancement Additional functionality, performance or other feature request
Milestone

Comments

@MogaSystems
Copy link

Is your feature request related to a problem? Please describe.

As per this forum post, I tried to store a ref to partial sub-tree of the object model in a variable for easier access and more readable code.

var tool = 0
var toolHeater = heat.heaters[tools[var.tool].heaters[0]]
 
;--- Accessing the "current" member. As of now, this is not possible:
echo var.toolHeater.current

;--- Expected behaviour would be the equivalent to:
echo heat.heaters[tools[var.tool].heaters[0]].current

Describe the solution you propose.

It would be a great addition to the syntax if we could somehow store object references in variables, then later dereference them as required, accessing the original part of the object model.

Describe alternatives you've considered

As of now, @dc42 has confirmed that this is not possible. The only way is to use a whole path to the endpoint at every place where it is required.

Provide any additional context or information.

No response

@MogaSystems MogaSystems added the enhancement Additional functionality, performance or other feature request label Feb 29, 2024
@w1ebr
Copy link

w1ebr commented Feb 29, 2024 via email

@MogaSystems
Copy link
Author

What about using string substitution (similar to using a preprocessor variable) vs referencing and dereferencing?

Hmm, could be a possible workaround, but is that possible? I just read the documentation twice again, but I did not find anything that evaluates a string's contents as a command.

@dc42
Copy link
Collaborator

dc42 commented Mar 1, 2024

Correct, there is no facility to interpret a string expression as a command.

@dc42 dc42 added this to the 3.5.1 milestone Mar 1, 2024
@dc42 dc42 modified the milestones: 3.5.1, 3.6.0 Apr 21, 2024
@T3P3 T3P3 modified the milestones: 3.6.0, After 3.6 Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Additional functionality, performance or other feature request
Projects
None yet
Development

No branches or pull requests

5 participants