#Can anybody explain what std.io.Reader.read function does?

1 messages · Page 1 of 1 (latest)

viral ledge
#

The buffer is the true output

#

You copy the data to your buffer, it returns how much it actually read

lament vine
#

ohh i think i get it now when i use the reader function on a File from std.io.getStdIn it gives back a Reader and the context is the File's context

viral ledge
#

yea

#

And the the read functions makes a read and puts it into your buffer and returns how much you actually read

lament vine
#

where is the buffer located in exactly?

viral ledge
#

Yours to choose

lament vine
#

i am guessing the readFn function is located somewhere else in the library depending on what i am reading from

viral ledge
#

writer and reader are interfaces

#

the readFn function is defined into the context

#

for example, File has a read function which is the readFn for the File Reader

lament vine
#

I understand

#

then it calls os.read for os-specific calls?

viral ledge
#

It will do what the context wants to do

#

for File yeah

#

I think is implemented around os.read