I wrote a basic implementation of streams/lazy-seqs[0]. Currently it uses a naming convention where an 's' is appended to the beginning of all the functions in order to differentiate between the stream version and the normal function. I was thinking that it may be better to just type tag the streams and then use defextend to extend all of the functions to work on the streams. I realized that there are two issues with this: 1. Tagging: when to tag the streams becomes an issue. They would have to be tagged sometime during scons
but problems come up when you have infinitely long streams where they have to be tagged as you access
the next element. Also when you are sconsing something onto an actual stream instead of a function that returns
a stream you may wind up tagging the stream twice. 2. Efficency: by tagging all of the streams, there would be a pretty large overhead because of the need to access the
the actual data that is tagged. When accessing elements that are far down the stream, this extra time can add up. In order to make way for the convention, I had to rename the original scar and scdr, set-car and set-cdr. There shouldn't be much of a problem there. Unfortunately I have not written any tests for the streams, so if someone wanted to help, that would be much appreciated. [0]https://github.com/arclanguage/anarki/blob/master/lib/streams.arc |