Replies: 3 comments 8 replies
-
Thanks for this post and for going more in-depth into the consequences of such a change! Solely based on the impacts this seems to have on other languages, I definitely think it makes more sense to only "merge" them on a case-by-case basis, as you did in 050ba02 and not rush in to a bigger design change that might just get in the way later on! |
Beta Was this translation helpful? Give feedback.
-
From a pure code point of view, I can definitely see why one might want to merge these. However, at a deeper meaning level, we really shouldn't. The point is that, for some languages, So, in fact, we should be moving towards deprecating the use of |
Beta Was this translation helpful? Give feedback.
-
From this discussion, are there any actionable changes we can make? |
Beta Was this translation helpful? Give feedback.
-
@samm82 mentioned in #3854 that because
varDec
andvarDecDef
are often implemented similarly, we might consider merging them in the DeclStatement typeclass. The idea is that the merged function would takeMaybe SValue
as its second input, and act like one of the two current functions depending on whether theMaybe SValue
isNothing
. I can see some pros and cons for it, so I'd like to lay them out so we can discuss them.varDec
only affects GOOL's internal state, andvarDecDef
does the same thing, but adds an extra line of code to assign the value to the variable. In the PR linked above, both functions are implemented using the same helper function, which definitely shows the advantages of merging the functions.C.varDecDef
calls thevarDec
from the typeclass as part of its implementation. This is what allows Swift to use its own implementation forvarDec
, but then also useC.varDecDef
.varDec
being a part of the instance thatC.varDecDef
can just call, it would need to be a separate function that is passed explicitly toC.varDecDef
. It's slightly less elegant, but it achieves the same thing.What are your thoughts? I don't really mind how it is now, but it might remove a small amount of redundant code if we were to merge the functions.
Beta Was this translation helpful? Give feedback.
All reactions