openlang

Adding label(Integer) breaks label(null) on rebuild

Small change, on paper. A library has label(String value) today, and the next release keeps it and adds label(Integer value).

Old compiled callers are fine. Their class files already name the String signature, and that is what they keep calling. Rebuilding is another story. An untouched label(null) compiled against the new pair stops compiling, because both overloads accept null and neither is more specific than the other. The original method never had to change for that to happen.

So the release note has two audiences. People who keep their binaries can skip it. People who rebuild from source may have to edit a line just to keep meaning what they already meant. I'm not against overloads, but that's a real cost to hand to someone who asked for nothing.

What should the migration advice say, and at what point is a new method name simply the kinder option?

后续讨论 4

顺着彼此的依据读下去
  1. 固定链接

    New name. labelNumber(Integer value) and done. Making every existing caller cast its nulls spreads the cost into code that has nothing to do with this change, and the library patch stays smaller too. Sharing the name has to buy something concrete beyond a tidier method list, and I don't see it yet.

  2. 固定链接

    Two artifacts, kept apart. One client binary compiled against the old declaration. Its source, kept as a rebuild fixture. They answer different questions.

    The binary shows which overload the old call site names, and nothing more. If the method body changed, review that on its own. For this release the evidence is the old binary run plus the source rebuild with label(null).

  3. 固定链接

    Agreed, and there's a bonus for whoever touches that caller next. labelNumber(null) says which operation was meant. A cast on label(null) keeps the old selection too, but to a later reader it looks like noise. Somebody tidying up will delete it as redundant and the build breaks again. If the cast route wins, the migration note needs a line explaining why the cast is there.

  4. 固定链接

    A separate name is a sensible default. The migration text still has to tell apart two callers who want different things. One wants the old string behavior and can write label((String) null). The other wants the numeric operation and should call the numeric method. Both edits remove the ambiguity, but they mean different things.

    The overload earns its place only if the shared name tells callers with typed arguments something useful about how the two operations relate. In that case the release note shows the broken null call, its explicit repair and the statement about existing binaries side by side. If nobody can describe that relationship with a real use, labelNumber is the better choice. It doesn't force a source decision on existing callers just to make the method list look uniform.

同一个问题的其他角度

  1. My function returns an array when all I asked for was a path

    Writing a PowerShell function from scratch for once (rather than squinting at someone else's), and it misbehaves in a way I c…

    回复 4最近活动 powershell
  2. My init set fill-column for exactly one buffer

    Had (setq fill-column 72) in my init for ages and only just noticed that M-q in a fresh buffer still wraps at 70. (In *scratc…

    回复 8最近活动 emacs-lisp
  3. Upgradeable means the storage layout is forever

    People hear proxy pattern and think the immutability problem went away. It moved. The proxy holds the state and forwards call…

    回复 3最近活动 solidity