Co-routines?

Levi Pearson levi at cold.org
Mon Jul 3 10:13:39 MDT 2006


On Jul 3, 2006, at 8:41 AM, Michael L Torrie wrote:

> On Sun, 2006-07-02 at 22:25 -0600, Levi Pearson wrote:
>> Ultimately, though, I think we would be better served by replacing C
>> and its descendants (C++, Java, etc.) with something more flexible.
>> Of course, I recognize this isn't a very popular view, but a man can
>> dream, can't he?
>
> Maybe like a language called D?  Actually I'm not sure D supports
> coroutines natively either, but people are working with these  
> constructs
> in D: http://www.digitalmars.com/d/archives/digitalmars/D/37188.html
>

If D ever matures and solidifies, it may become my favorite C- 
derivative.  I used it for an object oriented design class and found  
it fairly pleasant to work with when I could find all the  
documentation I needed, and rather frustrating when the documentation  
was out of sync with the language or missing entirely.  D is still  
also tied fairly strongly to the concept of procedure calls creating  
stack frames, though, so I don't think it will ever really embrace  
higher-level control constructs.

What I have in mind as a C replacement doesn't really exist in any  
mainstream language that I'm aware of, but is fairly close in  
semantics to a language called pre-scheme that's used to implement  
the virtual machine for the Scheme48 implementation of Scheme.   
Scheme itself has properties that make its use for low-level systems  
programming somewhat awkward, since it can be difficult to determine  
the memory allocation profile of a program while it's being written.   
Pre-scheme, on the other hand, uses manual memory allocation and  
disallows closures that can't be  optimized away at compile time.

Here's a paper on PreScheme: http://citeseer.ist.psu.edu/cache/papers/ 
cs/210/ftp:zSzzSzftp.nj.nec.comzSzpubzSzkelseyzSzprescheme.pdf/ 
kelsey97prescheme.pdf

The current implementation compiles PreScheme to C and doesn't  
support the downward continuations that would be necessary to  
implement coroutines, but neither of those facts are essential to the  
language itself, and downward continuations are explicitly mentioned  
as a possible feature.

I think a language with the semantics of PreScheme and a Dylan-like  
syntax that targets the intermediate language of gcc rather than C  
and includes downward continuations would be an extremely powerful  
and potentially popular systems programming language.

			--Levi


More information about the PLUG mailing list