Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

Support referencing one constant in another constant #53

Closed
nickidlugash opened this issue Jun 17, 2014 · 10 comments
Closed

Support referencing one constant in another constant #53

nickidlugash opened this issue Jun 17, 2014 · 10 comments

Comments

@nickidlugash
Copy link
Contributor

Can we support referencing one constant in another constant?

E.g.
"place-halo": "#faf3ed  ",
"country-halo": "place-halo"

Or

`"land": ""#ebe5e0",
`"country-halo": { "lighten": ["land", 10] }`

(The syntax in the second example is not valid – I just made it up to demonstrate that the ability to reference other constants could be useful once we have color functions: #38)

@tmcw
Copy link
Contributor

tmcw commented Jun 17, 2014

Hm, I'm not sure if this is a good can of worms to open:

"place-halo": "country-halo",
"country-halo": "place-halo"

@nickidlugash
Copy link
Contributor Author

Hm, I'm not sure if this is a good can of worms to open

@tmcw Can you elaborate? :)

@tmcw
Copy link
Contributor

tmcw commented Jun 17, 2014

In the example that I posted: if you support variables referencing each other, you support referencing each other in infinite loops: place-halo goes to country-halo, and vice versa, forever. We can detect these kinds of loops, but they make the implementation a little more complex.

Variable references will also make debugging a bit trickier - instead of just saying "constant reference here was invalid", we'd have to look up possibly multiple levels of reference to give a more specific error.

@nickidlugash
Copy link
Contributor Author

@tmcw I see. I had assumed in that example that it would error right away because the first constant is trying to reference a constant that has not yet been defined, but I didn't realize that the order does not matter.

If we don't think that referencing constants within constants is a good idea, perhaps we should just push this type of functionality to the future GUI, and not worry about it for now?

@tmcw
Copy link
Contributor

tmcw commented Jun 17, 2014

If we don't think that referencing constants within constants is a good idea, perhaps we should just push this type of functionality to the future GUI, and not worry about it for now?

👍 This is something we can keep in our pocket for now and implement in a GUI after we have more knowledge of how we visually design maps anyway.

@jfirebaugh
Copy link
Contributor

@nickidlugash Is this still needed given current UI technology?

@nickidlugash
Copy link
Contributor Author

@jfirebaugh the current UI is not yet there to support something like this (this is basically the idea behind constant transforms, but it is not implemented yet). I think we're pretty set on this eventually being something the UI will handle though, so we can close here.

@nickidlugash
Copy link
Contributor Author

I think we're pretty set on this eventually being something the UI will handle though, so we can close here.

Um...maybe not? #38 (comment)

@jfirebaugh
Copy link
Contributor

Haha... oops, I guess there's a downside to merging the history. This bug was closed by a commit from the lint repository that fixed cutting-room-floor/mapbox-gl-style-lint#53.

@jfirebaugh jfirebaugh reopened this Mar 12, 2015
@jfirebaugh
Copy link
Contributor

RIP constants.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants