Re: close(writefile)

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...
jimcbrown said...

Another good idea (probably in addition to this, but even on its own) would be to add an is_open() function, that takes an integer and test whether or not that integer currently can be used to represent a valid, open file.

There is a problem with this.

integer fn = open(this) 
close(fn) 
integer fn2 = open(that) 

Both fn and fn2 will have the same value (3)

Pete

Both fn and fn2 can be used for reading and/or writing to, so I don't see a problem with that - both have the same integer and represent the same open file.

The only obvious thing I see here would be mistaken identity - one assumes fn points to this even though fn really is pointing to that. (This is not unique to Euphoria though but applies to any program in any language that uses file descriptors (fds).)

I suppose it wouldn't be too much trouble to add another function that can attempt to return a filename for a given file descriptor (when applicable of course), but at this point you might be better off not using file handles at all, instead using read_file() and write_file() or read_lines() and write_lines(), and simply always passing the filename in as a string.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu