Abstract
The Algebra of Communicating Processes (ACP) is a theory that views sequences and choices as mathematical operations: multiplication and addition. Based on these base constructs others are defined, such as parallel merge, interruption and disruption.
Conventional programming languages may be enriched with ACP features, to gain declarative expressiveness. We have done this in SubScript, an extension to the Scala language. SubScript has high level support for sequences, choices and iterations in a style similar to parser generator languages. It also offers parallel composition operations, such as and- and or- parallelism, and dataflow.
The declarative style is also present in the way various execution modes are supported. Conventional programming languages often require some boilerplate code to run things in the background, in the GUI thread, or as event handlers. SubScript supports the same execution modes, but with minimal boilerplate. It is also easy to compose programs from blocks having different execution modes.
This paper introduces ACP and SubScript; it briefly describes the current implementation, and gives several examples.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
This paper contains some text fragments literally copied or adapted from the predecessor paper.
- 2.
This description of ACP has largely been taken from Wikipedia.
- 3.
There is also a semicolon to denote sequences. SubScript has a similar semicolon inference for line breaks as Scala.
- 4.
We can combine this way any kind of item for which implicit conversions to scripts are in scope; this yields an algebra of general items rather than just of processes.
- 5.
In general Scala’s operator precedence rules are followed, except for the dataflow operators; in Scala white space denotes function application; in SubScript it is sequential composition.
- 6.
Library scripts that refine into such special processes, may be more readable. For the time being we want a minimal set of new keywords.
- 7.
For convenience here is an implicit value so that it may be left out of parameter lists that have an implicit formal parameter of the node’s type.
- 8.
In annotations there is implicit instead of here. Thus @gui: is equivalent to @gui(there).
- 9.
These operators start with a percent sign; they are members of a larger family of operators that can suspend and resume operands. These operators are not meant to be memorized; rather they may be encapsulated in higher level scripts with descriptive names.
- 10.
is also valid syntax; this requires an implicit conversion to be in scope that turns the number into a script call.
- 11.
A useful definition for (see Sect. 4.9) triggered several syntax changes. E.g. rectangular brackets replaced parentheses to delimit process expressions. Script lambda’s are now also written between rectangular brackets. Script terms may now have the form (s) or {s}, with s a Scala value; such terms are method calls or script calls, possibly after implicit conversion. Normal code fragments had the form {s}; this became {!s!}.
- 12.
- 13.
Subscript web site: http://subscript-lang.org.
References
Thati, P., Agha, G.: An algebraic theory of actors and its application to a simple object-based language. In: Owe, O., Krogdahl, S., Lyche, T. (eds.) From Object-Orientation to Formal Methods. LNCS, vol. 2635, pp. 26–57. Springer, Heidelberg (2004)
Baeten, J.C.M.: A brief history of process algebra. Theor. Comput. Sci. 335, 131–146 (2005)
Boussinot, F.: Reactive c: an extension of c to program reactive systems. Softw. Pract. Experiance 21(4), 401–428 (1991)
Boussinot, F., Susini, J.F.: The sugarcubes tool box. In: Nets of Reactive Processes Implementation
van Delft, A.: Dataflow constructs for a language extension based on the algebra of communicating processes. In: Proceedings of 4th Workshop on Scala, SCALA 2013. ACM (2013)
van Delft, A.: Some new directions for ACP research. CoRR abs/1504.03719 (2015). http://arxiv.org/abs/1504.03719
Gaspari, M., Zavattaro, G.: An algebra of actors. In: Ciancarini, P., Fantechi, A., Gorrieri, R. (eds.) FMOODS, IFIP Conference Proceedings, vol. 139. Kluwer (1999)
Goeman, H.: Towards a theory of (self) applicative communicating processes: a short note. Inf. Process. Lett. 34(3), 139–142 (1990)
Hoare, C.: Communicating sequential processes. ACM Comput. Surv. 7(1), 80–112 (1985)
Johnson, S.: Yacc: Yet another compiler- compiler. Technical report, Bell Laboratories (1979)
Milner, R.: A Calculus of Communicating Systems. Springer-Verlag New York Inc., Secaucus (1982)
Milner, R., Parrow, J., Walker, D.: A calculus of mobile processes, part i. Inf. Comput. 100, 1–40 (1989)
Wang, Y.: Fully abstract game semantics for actors. CoRR abs/1403.6563 (2014)
Wills, P.: No more regular expressions. Scala Exchange, Skills Matter, London (2014)
Acknowledgement
We thank the referees and especially the shepherd for their useful suggestions and other comments.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing Switzerland
About this paper
Cite this paper
van Delft, A., Kmetyuk, A. (2016). Declarative Programming with Algebra. In: Kiselyov, O., King, A. (eds) Functional and Logic Programming. FLOPS 2016. Lecture Notes in Computer Science(), vol 9613. Springer, Cham. https://doi.org/10.1007/978-3-319-29604-3_15
Download citation
DOI: https://doi.org/10.1007/978-3-319-29604-3_15
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-29603-6
Online ISBN: 978-3-319-29604-3
eBook Packages: Computer ScienceComputer Science (R0)