home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18288 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.3 KB  |  60 lines

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