3 ms·
Maybe don't use such a primitive editor integration? I'm not trying to dunk on your editor, but people have had this problem solved since the early 90s. If you
by KirinDave 9y ago
Maybe don't use such a primitive editor integration?
I'm not trying to dunk on your editor, but people have had this problem solved since the early 90s. If your programmer's editor doesn't have some affordances for your language, then it's not a programmer's editor at all, it's a text editor.
- joshuamorton 9y agoI'm curious: what editor can do this? Consider that the codebase I work on is large enough that it cannot fit in a project file or ctags or similar. (Which is to say that VS, Clion, and others don't work, nor will vim (for this specific feature))
- KirinDave 9y agoFor which language? In the case of systems like Clojure, if you're introducing new toplevel bindings you're not going to get completion without direct interactive evaluation (naturally). But everything short of that should be well-formed. In many cases with common macros I'd add decls for Cursive Clojure + Idea to let me autocomplete introduced bindings. For example, I helped my editor understand unique structure, e.g., (defauthedendpoint get-frobnaz [request user] ...re<tab>quest)
- joshuamorton 9y agoC/C++. In the general case, I don't believe its possible to resolve macros without linking.
- KirinDave 9y agoActually, I'm not sure. If we're referring to the C pre-processor here, can't we always just run it through before symbolizing? I guess that without the right environment ifdef stuff falls out, but I dunno what to tell you there other than making builds contingent on the environment is a sketchy practice.
- joshuamorton 9y agoSo, say I have this: #include a.h #include b.h #include c.h MACRO(varname) welp.
- KirinDave 9y agoSince the include chain has to terminate, can't we just run the pre-processor over every file before we index it? Seems, um, like a pretty reasonable idea to me if you care about C-style macros (I sure don't.)
- majewsky 9y agoIt may be sketchy, but you may not have a choice. If you have a Qt application (written in C++) which needs to use a platform-specific API to do some magic stuff with a window, there's a method on the window to get the handle that the platform's GUI library offers. Of course that's going to be dependent on the environment because each environment has an entirely different GUI library (e.g. Cocoa only exists on macOS, not on Windows or Linux or Android).
- swift 9y agoI can't parse this in a way that it makes sense; I suspect you're mixing up some terminology. I'm guessing you mean that you need access to all transitively included headers to know a macro's definition. That's certainly true, but it's not linking, which involves resolving symbols in the object files that are the output of the compiler. The C preprocessor logically runs before the compiler; its output forms the compiler's input. You can run it without running the compiler at all.
- joshuamorton 9y agoAck, you're correct.
- yellowapple 9y agoOn the other hand, if my editor has to incorporate a full-blown parser for your program's (meta)language in order for me to find where something's defined, then maybe your program needs refactored more than my editor needs replaced. Or perhaps better documentation on your program's part and/or better education/familiarization on my part is warranted. Most modern editors are able to horizontally scroll and thus handle long lines in source code. That doesn't make a 500-character-long line of code acceptable by any stretch.
- KirinDave 9y ago> On the other hand, if my editor has to incorporate a full-blown parser for your program's (meta)language in order for me to find where something's defined, then maybe your program needs refactored more than my editor needs replaced. Either you want your editor aware of your language's semantics if you don't. I rather do, because it saves a ton of time and basic integrations are usually quite straightforward in 2017. > Or perhaps better documentation on your program's part and/or better education/familiarization on my part is warranted. Barring my opinions on this, I don't get why this would exclude editor semantics. > Most modern editors are able to horizontally scroll and thus handle long lines in source code. That doesn't make a 500-character-long line of code acceptable by any stretch. Okay, but this is a false equivalence. You're telling me not to use metaprogramming tools because they make it hard for a specific editor feature to be used in conjunction with them in the most difficult case for any system (introducing new run-time-dependent lexical bindings into a scoped block and handling that at compile time). But unlike code visibility, in most good solutions exist to work with these systems (within reason).