|
1 |
| -# pyro |
2 |
| -A π-calculus programming language and interpreter |
| 1 | +<h1 align="center">Pyro</h1> |
| 2 | +<p align="center"> |
| 3 | + <i>· π-calculus programming language ·</i> |
| 4 | +</p> |
| 5 | + |
| 6 | +<p align="center"> |
| 7 | + <img src="https://github.com/YoEight/pyro/assets/144545/7cebd746-09de-495c-a381-6d20e1b5c4ae" /> |
| 8 | +</p> |
| 9 | + |
| 10 | +## Key features |
| 11 | + |
| 12 | +* Functional oriented (mutation is not allow for now) |
| 13 | +* Strong nominal type system with inference for non top-level declarations. |
| 14 | +* Type checking can be disabled, leading type errors or missing variables to raise exceptions at runtime. |
| 15 | + |
| 16 | +## Syntax |
| 17 | + |
| 18 | +Current `Pyro` syntax is very close to the Pict programming language however, this might change in mid-long term. A syntax closer to OCAML might be implemented in the future. See [Pict Tutorial] for exhaustive examples and more. |
| 19 | + |
| 20 | +## Example |
| 21 | + |
| 22 | +``` |
| 23 | +run |
| 24 | + (def for [min: Integer max: Integer f:![Integer ^[]] done: ^[]] = |
| 25 | + (def loop x:Integer = |
| 26 | + if (<= x max) then |
| 27 | + (new c : ^[] |
| 28 | + ( f ! [x c] |
| 29 | + | c?[] = loop!(+ x 1))) |
| 30 | + else |
| 31 | + done ! [] |
| 32 | + loop ! min ) |
| 33 | + (new done : ^[] |
| 34 | + ( for! [1 4 |
| 35 | + \[x c] = (print ! x | c ! []) |
| 36 | + done] |
| 37 | + | done?[] = print ! "Done!"))) |
| 38 | +``` |
| 39 | + |
| 40 | +When executed, that program should produce the following output: |
| 41 | + |
| 42 | +``` |
| 43 | +1 |
| 44 | +2 |
| 45 | +3 |
| 46 | +4 |
| 47 | +"Done!" |
| 48 | +``` |
| 49 | + |
| 50 | +## Getting Started |
| 51 | + |
| 52 | +This repository contains an embeddable, a standalone runtime and a REPL. The codebase is entirely based on the Rust programming language. Version 1.70+ has been used to build the project but earlier versions of the compiler can work too. |
| 53 | + |
| 54 | +* `pyro`: Standalone interpreter |
| 55 | +* `pyro-core`: Common types but also contains the lexer, parser, inferencer and the type checker. |
| 56 | +* `pyro-runtime`: Embeddable interpreter. |
| 57 | +* `pyro-repl`: CLI-based REPL. |
| 58 | + |
| 59 | +You can build the whole codebase by running the following command: |
| 60 | +``` |
| 61 | +$ cargo build |
| 62 | +``` |
| 63 | + |
| 64 | +## About |
| 65 | + |
| 66 | +π-calculus is a theoretical model for concurrent computation that was developed by Robin Milner around the late 20th century. |
| 67 | +It's a mathematical framework used to describe and analyze the interactive behaviors of concurrent systems, where multiple computations are executing simultaneously and can interact with each other. |
| 68 | + |
| 69 | +In `Pyro`, computations are modeled as processes that communicate by passing messages through channels. The core features of `Pyro` are the ability to dynamically create new communication channels and to treat channels as first-class values that can be sent as part of messages. This allows `Pyro` to express dynamic network topologies, where the interconnections between components can change over time, which is a key aspect of distributed computing environments. |
| 70 | + |
| 71 | +The central idea is that these processes can not only send and receive information but also alter the network of communication. For instance, a process might create a new channel and send its name to other processes, which can then use this channel for future communication. This provides a powerful mechanism for expressing complex communication patterns. |
| 72 | + |
| 73 | +## Inspiration |
| 74 | + |
| 75 | +`Pyro` draws significant inspiration from the Pict programming language, one of the earliest implementations of the π-calculus theory in the form of a practical programming language. You can find more about the Pict programming language on the [Pict Homepage]. You can also find a [Pict presentation slides] and the [Pict tutorial] I used to implement `Pyro`. |
| 76 | + |
| 77 | +[Pict Homepage]: https://www.cis.upenn.edu/~bcpierce/papers/pict/Html/Pict.html |
| 78 | +[Pict presentation slides]: https://www-sop.inria.fr/mimosa/Pascal.Zimmer/mobility/pict.pdf |
| 79 | +[Pict tutorial]: https://www.cs.rpi.edu/academics/courses/spring04/dci/picttutorial.pdf |
0 commit comments