Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upBehavior of toString relying on special constructor names #288
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 2, 2015
Member
What do you propose to ameliorate this? I think we can make the risk of overlap small enough that this is not a concern in practice, and I'm not sure it'd be worth it to do anything fancier than that.
|
What do you propose to ameliorate this? I think we can make the risk of overlap small enough that this is not a concern in practice, and I'm not sure it'd be worth it to do anything fancier than that. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 2, 2015
Contributor
I agree. Name the constructors something like XXX_Set or whatever. Actually I guess the RBNode etc. constructors are not much of an issue, but specifically the constructor Set on the right-hand side of type Set t = Set (Dict.Dict t ()) is too likely to be used by somebody else. So, I'm for renaming that constructor, plus changing the toString function in Native/Show.js by adding a separate case matching on that new constructor (and removing the Set-subcase of the case for Dicts there).
|
I agree. Name the constructors something like |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 2, 2015
Contributor
I addressed the Set-related part of this in https://github.com/elm-lang/core/pull/323.
The only other constructors that are treated somehow specially in the native toString function and that could potentially be occurring in a user's Elm code (and thus potentially lead to conflicts) are RBNode and RBEmpty. So, one might want to replace those by something more "exotic" throughout the whole repository. Like RBNode_Internal and RBEmpty_Internal or so.
|
I addressed the The only other constructors that are treated somehow specially in the native |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 3, 2015
Member
A convention like Node_elm_builtin might do the job better. Perhaps someone will think their thing really is internal in their context, but no one should think their node is an elm builtin. Seems like a fine change either way.
|
A convention like |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Okay, same for |
jvoigtlaender commentedJul 1, 2015
For example, this currently leads to a runtime error:
because the
toStringimplementation inNative/Show.jssees theRBNodeconstructor name and "thinks" that type is aDict(because thecoreimplementation ofDictuses that constructor name as well).Similarly, the
Settype is not currently handled well intoString(after the #260/#263 change).