What's the purpose of the Word AST type?
#516
-
|
Looking at the Am I overlooking something? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
|
Good question. It exists to leverage the type system in distinguishing raw strings (that are not words-requiring expansion) from formal words in the grammar that require full expansion in accordance with the spec. This forces users of the type to make an explicit decision as to whether they want to convert it to a string or expand it via basic or full expansion. |
Beta Was this translation helpful? Give feedback.
-
Could you elaborate on what you mean by that? The way I understood, you're trying to say that the |
Beta Was this translation helpful? Give feedback.
The AST is designed to be intentional at when its nodes embed
Strings versus when it embedsWords. They are physically the same, but the latter are generally required to go through "word expansion" (see section 2.6 of the spec).There may be discrepancies in the code base. If they're intentional, ideally there would be a reason and sufficient commenting. And if not, then it may very well be a bug / oversight. Please do report any such issues!