META’18, November 4-9 2018, Boston MA, USA Jim E. Newton and Didier Verna
Decision tree techniques are useful in the ecient compilation
of pattern matching constructs in functional languages[
Mar08
].
An important concern in pattern matching compilation is nding
the best ordering of the variables which is known to be coNP-
Complete [
Bry86
]. However, when using BDDs to represent type
speciers, we obtain representation (pointer) equality, simply by us-
ing a consistent ordering; nding the best ordering is not necessary
for our application.
Charniak [
CM85
] explains a technique called discrimination net
to represent nested if-then-else machines. PCL (Portable Common
Loops)[
BKK
+
86
] which is the heart of many implementations of
the CLOS (the Common Lisp Object System) [
Kee89
,
Ano87
], in
particular the implementation within SBCL [
New15
], uses discrim-
ination nets to optimize generic function dispatch. In this article
we do not investigate the similarities and dierences between the
discrimination net approach and the ROBDD approach, except to
note that there is some obvious overlap in the problem space they
purport to solve.
8 CONCLUSION AND PERSPECTIVES
It is not clear whether Common Lisp could provide a way for a
type denition in an application program to extend the behavior of
subtypep
. Having such a capability would allow such an extension
for
rte
. Rational language theory provides a well dened algorithm
for deciding such questions given the relevant rational expressions
[HMU06, Sections 4.1.1, 4.2.1].
This article demonstrates the use of reection and meta-
programming to provide an elegant tool to the application pro-
grammer, namely regular type expressions. These regular type
expressions extend the already reective Common Lisp type sys-
tem, enabling the run-time program more exibility in reasoning
about heterogeneous lists.
Meta-programming is essential in our integration into the Com-
mon Lisp type system. Our approach involves computationally in-
tensive nite state machine based calculations which are executed
whenever the compiler encounters a new
rte
type declaration. The
result is that these calculated functions are thereafter available at
run-time for ecient type matching of lists in question.
REFERENCES
[Ake78]
S. B. Akers. Binary decision diagrams. IEEE Trans. Comput., 27(6):509–516,
June 1978.
[And99]
Henrik Reif Andersen. An introduction to binary decision diagrams.
Technical report, Course Notes on the WWW, 1999.
[Ano87]
Anonymous. The Common Lisp Object Standard (CLOS), October 1987. 1
videocassette (VHS) (53 min.).
[Ans94]
Ansi. American National Standard: Programming Language – Common
Lisp. ANSI X3.226:1994 (R1999), 1994.
[Aug85]
Lennart Augustsson. Compiling pattern matching. In Proc. Of a Conference
on Functional Programming Languages and Computer Architecture, pages
368–381, New York, NY, USA, 1985. Springer-Verlag New York, Inc.
[BCM
+
92]
J. R. Burch, E. M. Clarke, K. L. McMillan, D. L. Dill, and L. J. Hwang.
Symbolic model checking: 1020 states and beyond. Inf. Comput., 98(2):142–
170, June 1992.
[BKK
+
86]
D. G. Bobrow, K. Kahn, G. Kiczales, L. Masinter, Stek, M., and F. Zdy-
bel. Common Loops, merging Lisp and object-oriented programming.
j-SIGPLAN, 21(11):17–29, November 1986.
[Bla15]
Jim Blandy. The Rust Programming Language: Fast, Safe, and Beautiful.
O’Reilly Media, Inc., 2015.
[BRB90]
K. S. Brace, R. L. Rudell, and R. E. Bryant. Ecient implementation of
a bdd package. In 27th ACM/IEEE Design Automation Conference, pages
40–45, Jun 1990.
[Bry86]
Randal E. Bryant. Graph-Based Algorithms for Boolean Function Manipu-
lation. IEEE Transactions on Computers, 35:677–691, August 1986.
[Bry92]
Randal E. Bryant. Symbolic boolean manipulation with ordered binary-
decision diagrams. ACM Comput. Surv., 24(3):293–318, September 1992.
[Brz64]
Janusz A. Brzozowski. Derivatives of regular expressions. J. ACM,
11(4):481–494, October 1964.
[Bur13]
Eugene Burmako. Scala macros: Let our powers combine!: On how rich
syntax and static types work with metaprogramming. In Proceedings of
the 4th Workshop on Scala, SCALA ’13, pages 3:1–3:10, New York, NY, USA,
2013. ACM.
[Cas16]
Giuseppe Castagna. Covariance and contravariance: a fresh look at an old
issue. Technical report, CNRS, 2016.
[CB14]
Paul Chiusano and Rnar Bjarnason. Functional Programming in Scala.
Manning Publications Co., Greenwich, CT, USA, 1st edition, 2014.
[CBM90]
Olivier Coudert, Christian Berthet, and Jean Christophe Madre. Verication
of synchronous sequential machines based on symbolic execution. In
Proceedings of the International Workshop on Automatic Verication Methods
for Finite State Systems, pages 365–373, London, UK, UK, 1990. Springer-
Verlag.
[CD10]
Pascal Costanza and Theo D’Hondt. Embedding hygiene-compatible
macros in an unhygienic macro system. Journal of Universal Computer
Science, 16(2):271–295, jan 2010.
[Che17]
Tongfei Chen. Typesafe abstractions for tensor operations. CoRR,
abs/1710.06892, 2017.
[CL17]
G. Castagna and V. Lanvin. Gradual typing with union and intersection
types. Proc. ACM Program. Lang., (1, ICFP ’17, Article 41), sep 2017.
[CM85]
Eugene Charniak and Drew McDermott. Introduction to Articial Intelli-
gence. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA,
1985.
[Col13]
Maximilien Colange. Symmetry Re duction and Symbolic Data Structures
for Model Checking of Distributed Systems. Thèse de doctorat, Laboratoire
de l’Informatique de Paris VI, Université Pierre-et-Marie-Curie, France,
December 2013.
[GPS98]
Clemens Gröpl, Hans Jürgen Prömel, and Anand Srivastav. Size and
structure of random ordered binary decision diagrams. In STACS 98, pages
238–248. Springer Berlin Heidelberg, 1998.
[Gra96]
Paul Graham. ANSI Common Lisp. Prentice Hall Press, Upper Saddle River,
NJ, USA, 1996.
[HMU06]
John E. Hopcroft, Rajeev Motwani, and Jerey D. Ullman. Introduction
to Automata Theory, Languages, and Computation (3rd Edition). Addison-
Wesley Longman Publishing Co., Inc., Boston, MA, USA, 2006.
[Hro02]
Juraj Hromkovič. Descriptional complexity of nite automata: Concepts
and open problems. J. Autom. Lang. Comb., 7(4):519–531, September 2002.
[HVP05]
Haruo Hosoya, Jérôme Vouillon, and Benjamin C. Pierce. Regular expres-
sion types for XML. ACM Trans. Program. Lang. Syst., 27(1):46–90, January
2005.
[Jos12]
Nicolai M. Josuttis. The C++ Standard Library: A Tutorial and Reference.
Addison-Wesley Professional, 2nd edition, 2012.
[Kay69]
Alan C. Kay. The Reactive Engine. PhD thesis, University of Hamburg,
1969.
[Kee89]
Sonja E. Keene. Object-Oriented Programming in Common Lisp: a Program-
mer’s Guide to CLOS. Addison-Wesley, 1989.
[Knu09]
Donald E. Knuth. The Art of Computer Programming, Volume 4, Fascicle 1:
Bitwise Tricks & Techniques; Binary Decision Diagrams. Addison-Wesley
Professional, 12th edition, 2009.
[Lee59]
C. Y. Lee. Representation of switching circuits by binary-decision programs.
Bell System Technical Journal, 38(4):985–999, 1959.
[Mar08]
Luc Maranget. Compiling pattern matching to good decision trees. In
Proceedings of the 2008 ACM SIGPLAN Workshop on ML, ML ’08, pages
35–46, New York, NY, USA, 2008. ACM.
[McI60]
M. Douglas McIlroy. Macro instruction extensions of compiler languages.
Commun. ACM, 3:214–220, April 1960.
[NDV16]
Jim Newton, Akim Demaille, and Didier Verna. Type-Checking of Het-
erogeneous Sequences in Common Lisp. In European Lisp Symposium,
Kraków, Poland, May 2016.
[New15] William H. Newman. Steel Bank Common Lisp user manual, 2015.
[New16]
Jim Newton. Report: Ecient Dynamic Type Checking of Heterogeneous
Sequences. Technical report, EPITA/LRDE, 2016.
[New17]
Jim Newton. Analysis of algorithms calculating the maximal disjoint
decomposition of a set. Technical report, EPITA/LRDE, 2017.
[NV18]
Jim Newton and Didier Verna. Strategies for typecase optimization. In
European Lisp Symposium, Marbella, Spain, April 2018.
[NVC17]
Jim Newton, Didier Verna, and Maximilien Colange. Programmatic ma-
nipulation of Common Lisp type speciers. In European Lisp Symposium,
Brussels, Belgium, April 2017.
[ORT09]
Scott Owens, John Reppy, and Aaron Turon. Regular-expression deriva-
tives re-examined. J. Funct. Program., 19(2):173–190, March 2009.