4 ms·
This made me think: is there an IDE or plugin that makes it easy to visualize the source code of a function by inlining the sources of the undercalled functions
by Thunderya 7y ago
This made me think: is there an IDE or plugin that makes it easy to visualize the source code of a function by inlining the sources of the undercalled functions?
For example, before the transformation:
function isFooLike(x) {
return x.startsWith("foo");
}
function isBarLike(x) {
return x.startsWith("bar");
}
function bigFunction(str) {
if(isFooLike(str)) {
console.log("Foo!");
}
else if(isBarLike(str)) {
console.log("Bar!");
}
else {
console.log("Unknown!");
}
}
And then:
function bigFunction(str) {
if((function(x) {
return x.startsWith("foo")
})(str)) {
console.log("Foo!");
}
else if((function(x) {
return x.startsWith("bar")
})(str)) {
console.log("Bar!");
}
else {
console.log("Unknown!");
}
}
- ktpsns 7y agoWhile I find your inlined example very bad to read, I think there are many attemps IDEs do for this. I remember some showing the function stub of a called function when moving the mouse on the call instruction. I also know multiple editors that allow to quickly browse the source code with CTRL+Enter (or CTRL+Mouse click) in a similar fashion as we click on links in the web. I personally never found indirection to be a problem. It's rather the solution.
- Thunderya 7y agoYes unfortunately my example is not very readable, but it was to illustrate the idea of including the sources of the called functions. Indeed, many IDEs allow you to easily display the source code of one function at a time, by navigating to the sources of the function or by displaying it in a pop-up, but the idea I had in mind is to be able to view the source code of the function with all its dependencies at a glance.