fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

mutability in `io.buffered.reader`

Open fridis opened this issue 1 year ago • 0 comments

lib/io/buffered/reader.fz currently uses a mutate effect to create a mutable variable

  buffer := LM.env.new empty       

that is later modified like this

        buffer <- a
        replace

This is IMHO not necessary. Instead, we could replace the buffer by a new instance:

public reader(buffer (array u8 | io.end_of_file), rp Read_Provider, buf_size i32) : effect effect_mode.plain is

and later

        (reader a rp buf_size).replace

So instead of a mutable field buffer, we just create a new instance of reader and replace the old one. But maybe this comment is useless once the reader effect uses a mutable array.

fridis avatar Jul 30 '24 14:07 fridis