About the pattern matching algorithm in OCaml

点点圈 提交于 2020-01-12 05:42:10

问题


I am writing a compiler for a functional language I designed with OCaml. I want my little language to have the feature of pattern matching, however, I got stuck in coming up with an algorithm to implement it. It seems really complicated as I dig into the problem. I can't find much useful information about the corresponding algorithm with google. I will be appreciated if someone can give me some hint or point me to the resources. Or are there any tricks to take advantage of OCaml's power in pattern matching to solve this problem so that I don't need to implement it? Thanks!


回答1:


There's a few good papers on compiling pattern matching by some of the people behind OCaml. In particular see Compiling Pattern Matching to Good Decision Trees and Optimizing Pattern Matching. It might also be useful to go over this stackoverflow post.



来源:https://stackoverflow.com/questions/20233019/about-the-pattern-matching-algorithm-in-ocaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!