Respect / Config

A powerful, small, deadly simple configurator and dependency injection container DSL made to be easy
http://respect.github.io/Config
Other
98 stars 7 forks source link

Variable references inside sequences may not be working #25

Open alganet opened 12 years ago

alganet commented 12 years ago

Needs some tests, but it seems that something like foo = [[baz]] isn't expanding the baz variable properly. Output should be something compatible to $container->foo = array($container->baz).

alganet commented 12 years ago

I've imagined a fix for this.

This would probably fix another issues we had with lazy loading.

iannsp commented 12 years ago

I did a PR for this issue but it not solve the problem inside #25 as well.

The goal here is nested interpretation as fallow [[N]] = we have a variable variable, so ,

(a) A = 'datum' N = A foo = [[N]] => [[N]] => [A] => 'datum'

but the issue ask for something like

(b) [[N]] = we have a variable variable, so , A = 'datum' N = A foo = [[N]] => [[N]] => array('datum');

use the operators [] for both things(indicate array and variable association) generate this sort of mistake.

from the INI(and parse_ini ) point of view the (b) is more interesting, but from the PHP point of view I think the (a) have more "common sense" inside.

anyway, I will proper implement it.

nickl- commented 12 years ago

Yes left assign makes more sense, or are we speaking about something else?

Scratching head

nickl- commented 11 years ago

@respect Does anyone know what happened for PR #32 to be revoked? Is this not solving the issue?

alganet commented 11 years ago

I believe the PR was related to making a distinction between [] for declaring and using. I can't really remember, but I disagree we should separate the syntax.

The [bracket syntax] stands for a configuration block. If used before = is declaration, if used after = is passing, much similar to what $ does for variables in PHP.

nickl- commented 11 years ago

I am looking at #20 now and started wondering if we shouldn't make a better distinction between arrays and references (iow lookup to another declared value.) perhaps using an @ or as seems quite universal the use of $ to denote a reference or that it carries a defined meaning otherwise. Instead of using the [ ] which are ambiguous to i.) section names, ii.) array definitions, iii.) something I am forgetting.

This will solve the issue by means of:

[baz]
baz = 'me baz'
foo = [$baz]

Will give the result for foo as array("me baz")

Thoughts? Any motivations why we are using the [ ] brackets instead?