dk / io-lambda Goto Github PK
View Code? Open in Web Editor NEWnon-blocking I/O as lambda calculus
non-blocking I/O as lambda calculus
IO::Lambda - nonblocking IO in functional style =============================================== This module is another attempt to fight the horrors of non-blocking I/O programming. The simplicity of the sequential programming is only available when one employs threads, coroutines, or coprocesses. Otherwise state machines are to be built, often quite complex, which fact doesn't help the clarity of the code. This module uses closures to achieve clarity of sequential programming with single-process, single-thread, non-blocking I/O. The approach implemented in this module is strongly based on closures. It emulates the blocking style, so the collection of states is local, and can be collected under single subroutine. For example, a dumbed down HTTP protocol can be described like in the following scheme: writable { print $fh "GET /\r\n\r\n" or die; readable { sysread $fh or die; read_again; } } IO::Lambda features syntax where one can indeed use the lambda syntax. Below is a full-functioning code: use strict; use IO::Lambda qw(:lambda); use IO::Socket::INET; my $q = lambda { my ( $socket, $url) = @_; context $socket; writable { print $socket "GET $url HTTP/1.0\r\n\r\n"; my $buf = ''; readable { return $buf unless sysread( $socket, $buf, 1024, length($buf)); again; } } }; print $q-> wait( IO::Socket::INET-> new( PeerAddr => 'www.perl.com', PeerPort => 80 ), '/index.html' ); For more examples, see eg/ directory.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.