Clang-expand: Expand function invocations into current scope
1–10 of 17 posts
Re: Clang-expand: Expand function invocations into current scope
#2Also instead of always replacing the text, it could also be an overlay, where the function call is temporarily expanded in your IDE while in some special mode.
Re: Clang-expand: Expand function invocations into current scope
#3Very very nice. But it should really be an action in clangd instead of its own tool, for simple integration with LSP. Also instead of always replacing the text, it could also be an overlay, where the function call is temporarily expanded in your IDE while in some special mode.
I was surprised it wasn't combined with clangd.
Re: Clang-expand: Expand function invocations into current scope
#4 let cell = self.cell_mut(pos);
Becomes: let cell = {
let ref mut this = self;
&mut this.board[usize::from(pos)]
};
Instead of: let cell = &mut self.board[usize::from(pos)];
It did manage to simplify the argument (maybe because it was the same name?) but had to rename `self`.Re: Clang-expand: Expand function invocations into current scope
#5Re: Clang-expand: Expand function invocations into current scope
#6What about by-hand-inlining `std::find` makes the code better?
Re: Clang-expand: Expand function invocations into current scope
#7Maybe I'm the only one, but... why? What about by-hand-inlining `std::find` makes the code better?
You can already expand macros at call site in any major C++ editor, so why not functions as well?
I would like this mainly just for making source exploration easier. Visual Studio and Clion have a "peek" feature that does something similar, but as a purely UI element, but Emacs' implementation of peek from LSP works much worse.
Re: Clang-expand: Expand function invocations into current scope
#8Maybe I'm the only one, but... why? What about by-hand-inlining `std::find` makes the code better?
Re: Clang-expand: Expand function invocations into current scope
#9Maybe I'm the only one, but... why? What about by-hand-inlining `std::find` makes the code better?
Re: Clang-expand: Expand function invocations into current scope
#10Maybe I'm the only one, but... why? What about by-hand-inlining `std::find` makes the code better?
Moreover things like SFINAE, variadic functions, and macros can make some libraries really opaque. Stuff like loggers, pub-subs, SERDES code... there will be a lot of template complexity and other indirection where this tool would help dramatically in peeling back the layers and could be used in place of breakpoints or a traditional debugger. (And it can often be hard to set up a debug session for large systems).
Can also be useful when you want to take an existing function and customize it for the call site versus write a new helper. For example maybe you want std::find_if() but instead of writing a lambda predicate you want some other code embedded into the body of the loop.