From: anton@mips.complang.tuwien.ac.at   
      
   albert@spenarnc.xs4all.nl writes:   
   >In article <2025Nov21.091552@mips.complang.tuwien.ac.at>,   
   >Anton Ertl wrote:   
   >>The behaviour is specified exactly:   
   >>   
   >>|If a line terminator was received before u1 characters were read, then   
   >>|u2 is the number of characters, not including the line terminator,   
   >>|actually read [...]. When u1 = u2 the line terminator has   
   >>|yet to be reached.   
   >   
   >The problem is that it builds on the 70' CORE and idea's. It is akward.   
      
   The complexity of READ-LINE's specification comes from the following   
   requirements:   
      
   * Do not ALLOCATE (ALLOCATE is not guaranteed to be present, and   
    probably is not present on small systems), so the caller of   
    READ-LINE has to pass in buffer description.   
      
   * Support arbitrarily long lines (that's a post-1970s attitude, BTW).   
      
   * Report the end of the file.   
      
   Did I forget a requirement?   
      
   If the first requirement was dropped, the specification could become   
   much simpler, e.g.,   
      
    READ-ALLOC-LINE ( file-id -- c-addr u ior )   
      
    If an error happens during the operation, return 0 0 n!=0; in that   
    case the file position after the operation may be anywhere between   
    the start of the line and end of the line (both included).   
      
    If READ-ALLOC-LINE is called when the file position is at the end of   
    the file, return 0 0 0.   
      
    Otherwise, c-addr u describes the contents of the line (without   
    terminator, even if there is one) and ior is 0. The line lives in   
    ALLOCATEd data space and the caller of READ-ALLOC-LINE is   
    responsible for FREEing it. After READ-ALLOC-LINE, the file   
    position points at the start of the next line.   
      
   READ-ALLOC-LINE can be implemented using READ-LINE, ALLOCATE and   
   RESIZE. I fail to come up with a use of READ-LINE with fixed-size   
   buffers and arbitrarily long lines that cannot be implemented just as   
   well with READ-FILE and the knowledge what bytes may represent   
   newlines.   
      
   - anton   
   --   
   M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html   
   comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html   
    New standard: https://forth-standard.org/   
   EuroForth 2025 CFP: http://www.euroforth.org/ef25/cfp.html   
   EuroForth 2025 registration: https://euro.theforth.net/   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|