Rename content fields to value - #4215
Conversation
Currently there are 43 matches for `name: value` and only 4 for `name: content` in `config.yml` `RationalNode`/`ImaginaryNode` also have `value` from node extensions. The one I particularly care about is `StringNode` because I often handle `SymbolNode` and `StringNode` the same way but I have to write different code becaues the fields are not named the same. This allows to ducktype them and I don't have to keep in mind when to use content vs value. `value` for a literal sounds better to me.
fc643c4 to
0235374
Compare
|
Wouldn't you want require 'prism'
code = <<'RUBY'
"a\nb"
RUBY
node = Prism.parse(code).value.statements.body[0]
pp node
p node.content
p node.unescapedgives: |
|
SymbolNode does indeed name |
|
Or IOW, I would expect (apologies for the many comments, just trying to explain my thoughts on this) |
|
That did not cross my mind. Yes, I would want the unescaped one and have probably not done so many times when I should have for correctness. Let me update this to a different approach. However I'm not so convinced anymore since the distinction between value/content is not immediatly obvious when both are present. |
|
Yeah I'm very hesitant on this. If I were to call |
|
Not sure I'm following. What should |
I believe Kevin means with the newline resolved, since it would be a Symbol object corresponding to the source. I'd imagine changing SymbolNode#value to return a Symbol instead of a String is tough for compatibility. |
Currently there are 43 matches for
name: valueand only 4 forname: contentinconfig.ymlRationalNode/ImaginaryNodealso havevaluefrom node extensions.(of course, most of the 43 are not for literals but for child nodes like in the RHS of
a = 1)The one I particularly care about is
StringNodebecause I often handleSymbolNodeandStringNodethe same way but I have to write different code becaues the fields are not named the same. This allows to ducktype them and I don't have to keep in mind when to usecontentvsvalue.valuefor a literal also sounds better to me.Same as in #4060, keep the previous names around.