Coroutines in Lua

Link: The Lua folks discuss their implementation of coroutines, using Create, Resume and Yield methods.

Lua implements the concept of asymmetric coroutines, which are commonly denoted as semi-symmetric or semi-coroutines. Asymmetric coroutine facilities are so called because they involve two types of control transfer operations: one for (re)invoking a coroutine and one for suspending it, the latter returning control to the coroutine invoker. An asymmetric coroutine can be regarded as subordinate to its caller, the relationship between them being similar to that between a called and a calling routine.

Lua coroutine facilities provide three basic operations: create, resume and yield... Function coroutine.create creates a new coroutine, and allocates a separate stack for its execution... Function coroutine.resume (re)activates a coroutine, and receives as its required first argument the coroutine reference... A coroutine suspends by calling function coroutine.yield in this case, the coroutine’s execution state is saved and the corresponding call to coroutine.resume returns immediately.

The main difference with typical thread implementations is that (a). the caller is suspended until completion and (b). a coroutine can return values like a function call. I suppose I'd summarize it as functions that retain state between calls.

Back to the language roots

Link: The article discusses the future of HDLs given the encroachment of software programming languages.

It's not time for the revolution yet. Traditional hardware-description languages have specific features that make them superior to software programming languages; although SystemC has its place in the hardware-design process, it still can't compete with Verilog and VHDL...
Verilog may have C-like syntax and VHDL an Ada-like syntax, but there are significantly different concepts in HDLs and software programming languages. Most importantly, an HDL adds the notions of concurrency and time.

From a PL perspective, it always seems to get back to whether a dedicated language is better suited than a more flexible general purpose one. And whether the specifications are best verified within the language or by a suite of tools and tests.

How birds learn songs

Research on Teaching Birds to Sing. Since we periodically delve into general language issues, I thought this work might be of interest since it is related to language learning.

Learning how baby sparrows learn to sing their songs could provide clues to how humans learn to speak languages. University of Utah biologist Gary J. Rose and his colleagues have taught baby sparrows to sing a complete song, even though the birds were exposed only to overlapping segments of the tune rather than the full melody.

(Though, we still appear years away from providing a general purpose PL for the winged community. And even then, we'll have to engage a full combinatory community).

Tim Bray: Sun & Dynamic Java

Tim Bray,

So on Tuesday we held a summit here at Sun, with a few of our internal Java leaders, and on the dynamic-languages side, Larry Wall and Dan Sugalski (Perl and Parrot), Guido van Rossum, Samuele Pedroni and Sean McGrath (Python), and James Strachan (Groovy). It was an educational day for us; herewith some take-aways and pictures.

Everyone and his sister is linking to this blog post, so you might have seen it already.

For a touch of flavor, here’s just part of the list that of things to discuss that Larry had prepared: anonymous code/closures, lvalue methods/functions, variadic call/return, constant/rw/copy/ref/lazy parameters, wrappers/AOP, eval, exception handling/undef/nil/unthrown exceptions, exception handlers with lexical access, temporization/hypotheticality, efficient regex with complete semantics, access to dynamic context/want/caller, redispatch of methods (fallback upon "fail"), efficient switch statement?, versioned modules/classes, virtual classnames, continuations.

Feel free to express your opinion regarding this list, and other relevant factors.

Casting SPELs in Lisp

A short and sweet Lisp tutorial that has the courage to introduce macros to absolute beginners.

The reader is shown how to build a simple text adventure game using Lisp. The code is available for download.

The IDE Divide

(via Keith)

Oliver Steele:

The developer world is divided into two camps. Language mavens wax rhapsodic about the power of higher-level programming — first-class functions, staged programming, AOP, MOPs, and reflection. Tool mavens are skilled at the use of integrated build and debug tools, integrated documentation, code completion, refactoring, and code comprehension....

You can be the only one on a team to use Eclipse. If you’re the only one on your team using Haskell, something is probably wrong.

It has been awhile sine we had a good IDE war er.. discussion...

The distinction between language mavens and tool mavens rings true. It shouldn't be too hard to guess to which camp I belong... I rarely spend time thinking about IDE issues if I can only help it.

Extending Ruby with C

I've generally found that the APIs for bridging the gap between Perl and C are either cryptic (XS) or fragile (Inline::C). While Python is better in some ways, I still find its C API rather difficult to read. Tools such as SWIG can help alleviate this problem, but you still need to write a bunch of glue code to bridge the gap between the high-level agile languages and the low-level C code.

When I first looked at doing the same kind of thing for Ruby, a whole new world opened up. The APIs are simple, to the point where I was up and running in minutes rather than hours.

A nice tutorial article on extending Ruby by providing access to a C library (GenX).

It has been awhile since we discussed language extension mechanisms and multi-language programming, yet these techniques are quite important when building real life systems.

Haskell Communities and Activities Report, Seventh Edition, November 2004

The November 2004 edition of the biannual Haskell Communities and Activities Report has been published. Lots of new stuff in the last six months, and some old stuff updated as well. The HC&AR has been steadily growing over the last three years, showing that FP is gaining users both professional and private.

Several of the HC&AR items are interesting enough to have their own LtU stories, which may appear shortly.

OOPSLA essays track

The program chair for OOPSLA 2005, Richard P. Gabriel, wants to shake things up. As part of that he's going to institute an Essays track, and I will be program chair for that track. I'm hunting for people to serve on the committee. -- Brian Marick

Might want to send in your suggestions.

Me, I am going to think of an essay topic...

End Users to Shape Effective Software

This might be an interestng project to keep an eye on.

The papers seem to cover a wide range of topics relevant to end user programming in a variety of settings.

XML feed