Do some Functional programming constructs reduce Debuggability?

前端 未结 5 1146
轮回少年
轮回少年 2021-01-02 06:14

I\'ve heard that the following features reduce debuggability (because they are anonymous and debuggers cannot trace it well)

  1. Anonymous Classes
  2. Inner C
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-02 06:59

    I would say this is decidedly untrue. Yes, without additional debugging support these constructs can be a bit more difficult to debug. In many languages they are not truly anonymous because the debugger doesn't understand language semantics. Instead it understands the final form of the program (the .exe and PDB combo). Most anonymous constructs eventually take concrete form in the final program (very true for .Net implementations).

    Additionally languages that implement these features often take the time to implement better debugging support for them. Take C# and VB for example

    1. Both languages add DebuggerDisplay attributes and override .ToString on the anonymous types the generate to increase debugging support. The implementations differ a bit but the result is pretty much the same.
    2. Inner classes aren't very special in terms of debugging and don't require much if any additional work
    3. VB and C# spent a lot of time in Visual Studio 2008 to "unwind" lambda expressions and show the captured free variables as part of the original locals list. Makes it much easier to debug a function

提交回复
热议问题