eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ConsStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ConsStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--ConsStream

Package:
stx:libbasic2
Category:
Collections-Linked
Version:
rev: 1.7 date: 2023/11/24 13:50:54
user: cg
file: ConsStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


A read stream on a list (of conses)
Conses are not heavily used by Smalltalk (actually: not at all).
Consider this a demo class.

copyright

COPYRIGHT (c) 2003 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  on: aCons


Instance protocol:

accessing
o  list: something

reading
o  atEnd
(comment from inherited method)
return true if the end of the stream has been reached;
- we do not know here how to do it, it must be redefined in subclass

stream protocol-reading
o  next
(comment from inherited method)
return the next element of the stream
- we do not know here how to do it, it must be redefined in subclass


Examples:


    |list s|

    list := Cons fromArray:#(1 2 3 4).   
    s := list readStream.
    [s atEnd] whileFalse:[
        Transcript showCR:(s next).
    ].
    |gen allNumbers s|

    gen := [:n | LazyCons car:n cdr:[ gen value:n+1 ]].
    allNumbers := gen value:1.

    s := allNumbers readStream.
    100 timesRepeat:[
        Transcript showCR:(s next).
    ].


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 14:19:03 GMT