GithubHelp home page GithubHelp logo

coro's Introduction

coro

Coro: a language with first-class support for coroutines.

The goal is to design and build a language that implements "asymmetric coroutines", as described in [1], supporting the core create/resume/yield operations. The language is meant to be a "toy" programming language, but the implementation should be mostly working well.

Example

# A simple generator that yields natural numbers.

def nat = {
  let n = -1;
  while true do {
    let n = n + 1;
    yield n;
  } end
}

let co = create nat

let i = 0
while i < 10 do {
  print (resume co);
  let i = i + 1;
} end

Building and Testing

Use cargo to build, run, and test the implementation. There is also a Makefile for your convenience. There are a few debug features you can pass to cargo:

  • ast - prints the AST after parsing
  • dbg - general debugging, prints out result values, coroutine status, etc.
  • instr - print the compiled linear instructions for each function
  • stack - print the value stack while executing instructions

You can pass these to Cargo like so:

$ cargo run --features=ast,dbg,instr,stack

References

[1] A. L. D. Moura and R. Ierusalimschy, “Revisiting coroutines,” ACM Trans. Program. Lang. Syst., vol. 31, no. 2, Feb. 2009, issn: 0164-0925. [Online]. Available: https://doi.acm.org/10.1145/1462166.1462167.

coro's People

Contributors

yufengwng avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.