[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Stream command processing (long message)



filter-cstream symbol? <lists.scm | map-cstream list >single-level-list.scm

into

(call-with-output-file
    "single-level-list.scm"
    (filter-cstream
	(map-cstream
	    (call-with-input-file
		"lists.scm"
		read-cstream)
	    list)
	symbol?))

----------------------------------------------------------------------
Why the extraneous syntax when you can do the following

(define (>> file-name stream)
  (call-with-output-file file-name stream))

(define (<< file-name)
  (call-with-input-file file-name read-cstream))

(define (|| what . args)
  (lambda (stream)
    (apply what (cons stream args))))

(>> "single-level-list.scm"
    ((|| filter-cstream symbol?)
     ((|| map-cstream list)
      (<< "lists.scm"))))

which except for the parentheses and the fact that it is left-to-right
inverted with respect to Unix is extremely close.

Sorry, but I feel that

(call-with-output-file
    "single-level-list.scm"
    (filter-cstream
	(map-cstream
	    (call-with-input-file
		"lists.scm"
		read-cstream)
	    list)
	symbol?))

is considerably clerarer than Unix-like syntax.  It is also more
powerful since the Unix shell syntax does not allow (as far as I know)
forking or merging streams in interesting ways, both of which scheme
procedures can easily accomodate.

A portable continuation stream top level of the sort you suggest is an
afternoon's worth of work, and does not really add any power or
interesting functionality to the language, so it might as well be
provided as part of the continuation stream utilities.