While reviewing the 2020-03-11 SIP meeting notes, I noticed a variety of proposed changes that, taken together, will absolutely clobber my existing code in the absence of a workaround. They’ve been mentioned before, but I only just realized now some of the interactions.
Of course, some of these probably have workarounds, or are less bad than they seem (because there are flags to change the behavior, at least temporarily).
Is there, or can there be, a place where workarounds are collected for all dropped features? I think this may be a relatively high priority when deciding upon whether changes should really go ahead, because without them (and without the list of dropped features) it’s hard for people to judge how much burden it would be to rewrite their code, and thus also make it hard for them to give accurate feedback.
I’ll give one example, about the pair of features that would potentially impact me the most–macros are changing and nonlocal returns are going away.
I use a macro to create a relatively straightforward rewrite of foo.?
to
foo match {
case Right(r) => r
case Left(err) => return Left(err)
}
which mirrors Rust’s ?
operator, except even better because it works inside collections operations etc. due to non-local returns.
The original rewrite seems doable with the splice-style macros in dotty. But if you don’t have nonlocal returns built in, the rewrite is considerably trickier–you need to take the entire enclosing method body, wrap it in a nonlocal-return-block, but only if it’s not already in one, and then do the local rewrite. Can dotty macros do that?! It seems doubtful–you have to explore outwards from the use site to the surrounding context. And this is absolutely ubiquitous in my code–something like 1/6th of my methods use this (in the largest codebase I’m currently working on).
Now, I have a sketch for a workaround in my head which would be merely quite painful to implement rather than practically impossible.
But it would be nice to have a place to be able to discuss concerns like this. If there is one already, where? If not, can we get one?