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

Allow assignment by reference #1037

Open
ScreamingDev opened this issue May 30, 2020 · 2 comments
Open

Allow assignment by reference #1037

ScreamingDev opened this issue May 30, 2020 · 2 comments

Comments

@ScreamingDev
Copy link

Foo:
  someFoo:
    abc: "source and solution to all our problems"
Bar:
  someBar:
    beer: "@someFoo->abc"

The value resolver usually copy a value from one item to another when using @someFoo->abc here. But instead of a copy I may want to have a reference to the other field.

So what Alice does is:

$someBar->beer = $someFoo->abc

But how to achieve this?

$someBar->beer =& $someFoo->abc

This feels missing when generating objects.

Please note: This is not a discussion about references, how valuable they are and when to do them. I do not want to chat about the pro and cons of references neither about specific use-cases. This is a plain simple note that Alice does not seem to be able to assign by reference and I hope for some solution to that.

@theofidry
Copy link
Member

There is indeed no support for this at the moment. If you feel it is necessary, I'll gladly accept a PR about it although I think it would be easier with #998

@ScreamingDev
Copy link
Author

So in the end there may be

  1. an adapter from YAML to the new Alice API structure as described in Change Alice API #998
  2. An additional syntax for creating references like
Foo:
  someFoo:
    abc: "source and solution to all our problems"
Bar:
  someBar:
    beer: "@&someFoo->abc"
    # note the ampersand above

or something else.

So I like to change this issue to:

Please allow references in the new Alice API

@theofidry theofidry changed the title Assign by reference Allow assignment by reference Aug 28, 2020
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