Skip to content

Conversation

rocallahan
Copy link
Contributor

What are the reasons/motivation for this change?

It's exactly the same as log_id(). log_id() occurs 1247 times before this PR, id2cstr() only occurs 77 times, so it makes sense to get rid of id2cstr() to reduce confusion/maintenance work.

Explain how this is achieved.

Trivial change. We leave id2cstr() in place, but deprecated.

@KrystalDelusion
Copy link
Member

I prefer id2cstr as the less confusing option given that log_id doesn't log even though it starts with log_*. What's the status of using the IdString natively and not needing to wrap it at all?

@rocallahan
Copy link
Contributor Author

I prefer id2cstr as the less confusing option given that log_id doesn't log even though it starts with log_*.

Fair point, but on the other hand id2cstr returns something different from IdString::c_str(), so that's also confusing.

The best name here is probably unescape_id(). Which already exists and does what we want. So maybe the best move here is just to replace id2cstr() and log_id() with unescape_id().

What's the status of using the IdString natively and not needing to wrap it at all?

That is already allowed, but it returns the same thing as IdString::c_str(), i.e. the name with the leading \ or $. We need something at the call site to indicate that a leading \ should be dropped. Obvious options:

  • A function call (e.g. unescape_id(id))
  • A method call (e.g. id.unescape())
  • Something in the format string (e.g. log("%#s", id))

Come to think of it, I actually prefer the method call. Let me do a Discourse post about it.

@rocallahan rocallahan marked this pull request as draft September 17, 2025 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants