Is there any built-in function for human-readable F# quotations?

后端 未结 3 964
闹比i
闹比i 2021-01-13 10:47

When quoting

<@ 1 + 1 @>

I want \"1 + 1\"

instead of

\"Call (None, Int32 op_Addition[Int32,Int32,Int32](Int32

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-13 11:21

    There is none, and it's not quite that easy, except in very simple cases. One of the main problems, for example, is the match construct. It is syntactic sugar for a whole bunch of if and switch statements (try printing a quotation with a match in, you'll see). Another one of those biggies are computation expressions, but I guess you could skip those at first.

    Then there is a the rabbit hole of ambiguities you'll have to resolve, with conventions like the pipe operator starts a new line, let starts a new line, indentation, infix, prefix, special cases like the (::) operator and so forth.

    All in all, doable, but not trivial. Sort of like decompiling.

提交回复
热议问题