home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Give me safe C++
- Message-ID: <1992Dec21.232417.18298@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Dec14.190553.14838@mole-end.matawan.nj.us> <1992Dec17.192301.23525@ucc.su.OZ.AU> <24437@alice.att.com>
- Date: Mon, 21 Dec 1992 23:24:17 GMT
- Lines: 47
-
- In article <24437@alice.att.com> ark@alice.UUCP () writes:
- >In article <1992Dec17.192301.23525@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >
- >> Next, I feel NO language has addressed the concept
- >> of coroutines (except possibly Simula?).
- >
- >Well, there's the C++ task package.
-
- Which one? (But tasks aren't coroutines anyhow. I think
- objects themselves come as close as I've seen in C++).
-
- >
- >More generally, coroutines require some kind of support for
- >multiple stacks, which can be a tricky problem in the absence
- >of garbage collection.
-
- Or in a machine that uses a stack to implement
- activation records. But if the activation records are placed
- in the heap and threaded togther with pointers the problem
- disappears.
-
- > One would therefore expect to find
- >coroutine support in at least some languages that have
- >garbage collectors, and indeed there is: Icon and Scheme
- >come to mind, as well as local extensions in some implementations
- >of ML.
-
- Ah, I shall have to look up how its done there sometime.
- Coroutines are useful for problems which are not block
- structured but have non-overlapping scopes. Subroutines
- really hamper proper expression of the solution then.
- A classic case of control inversion where subroutines
- are used, but coroutines are more correct,
- can be seen by comparing the COBOL and PL/1 sort facilities.
-
- Another example might be in a parser/lexer where you want
- to have the lexer say 'puttoken' and the parser say 'gettoken',
- and have these calls bound together. I guess you
- can emulate this with objects, I wonder if there
- is a standard idiom?
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-