introduce Generator type with string handling strategy options#682
introduce Generator type with string handling strategy options#682mbenson wants to merge 2 commits into
Conversation
|
The |
|
Hi @mbenson! Thanks for working on this. Unfortunately the I do agree that what you've proposed here is a plausible design for solving one specific annoyance with I think before we could move forward here we'd need to establish what the overall design goals for this package even are, what patterns it intends to follow, what are the intended limits to its scope, etc. Then it would be possible to compare what you proposed with those decisions to decide if this design is a good fit. I realize this is a very unsatisfying response. I wish I could give you some more concrete feedback that could result in immediate progress, but I'm afraid nobody is working in this area at the moment to give this the full review it deserves, and what you've contributed here is significant enough that it would represent a constraint on how this package could evolve in future. Therefore I don't really know how we can move forward here. If I had infinite time I'd love to think more deeply about what Therefore much as the issues you linked to have been in limbo, so will be this PR. I don't like it, but I'm afraid Thanks again for working on this, and I'm sorry this is the best I can do with this at the moment. |
There have been for several years a number of open issues relating to interpolation sequences in string literals. The community approach seems typically to hand-code these on an individual basis, which is simple enough, but when such strings are potentially embedded in more complex constructs there reaches a point where it makes more sense to support the preservation/non-escaping of such sequences in
hclproper. To that end, this PR introduces aGeneratortype that can be parameterized with options to guide token generation behavior in a manner that supports nested structures as described. The options structure, at time of submission is:e.g., to handle
stringtypes as templates, you would createGenerator{GenerateOptions{Handling{String: AsTemplate}}}.Note that the template handling panics if the value cannot be lexed; it might make sense to return an
errorfrom theGeneratormethods and translate these topanicfor the legacy functions only. If this is desired, I am glad to make the change.#442
#615
#392