Git Product home page Git Product logo

coddled-super-centaurs's Introduction

coddled-super-centaurs

A reimplementation of the stateful transducers from clojure.core, in a way that opens their states to extension.

Why?

Suppose you want to use stateful transducers in a context in which you need control over their states, for example to persist their states to disk and restore them.

If you try to do this with the ones in clojure.core, you will run into a snag: they construct their states themselves in a lexical scope, usually a value in a volatile!, sometimes a java collection... not something that is easy for you to extend from Clojure.

If volatile! were a dynamic function, then you could replace its implementation in order to manage the transducer's state yourself.

Since it is not, there is no straightforward way to access a transducer's state, unless the transducer is implemented to allow this. They generally are not open to this sort of extension. The functions in clojure.core which return stateful transducers are not. Replicas of all of them are provided in this library (only the arity that returns the stateful transducer).

Their implementations are trivially different from those in clojure.core. The main difference is that instead of calling volatile! to construct their state, they call a dynamic function coddled-super-centaurs.core/*state* and expect it to return a volatile!. Also, instead of a java.util.ArrayList they use a vector in a volatile!.

Performance

I have not bothered to do any benchmarking, however these are bound to be slower than their clojure.core counterparts, since they are identical but for the addition of some indirection and the use of Clojure collections instead of Java collections. You should not use these unless you need control over the states.

Usage

See their usage in noah, which was my motivation for this.

License

Copyright © 2019 Blake Miller

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

coddled-super-centaurs's People

Contributors

blak3mill3r avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.