Re: Problems with GET.E
- Posted by "Boehme, Gabriel" <gboehme at POSTOFFICE.MUSICLAND.COM> Nov 15, 1999
- 568 views
Robert Craig wrote (in response to Rod Jackson): >>Correct me if I'm wrong, but aren't several get() calls >>in a row supposed to return all of the objects that were >>printed to the file? ... > >get() requires that there be at least one character of >whitespace (blank, tab or new-line) separating the >top-level objects in the file. > >[...] > >>From what I can see, one way to do it >>would be to have print() put a space after every object >>it outputs. > >What about the users of print() who don't want the >extra space? Is it that hard to add: > puts(fn, ' ') >to your code? I don't think it's so much a case of how easy or hard it is to add "puts(fn, ' ')" to a given section of code. For me, at least, it's a case of paired functions having a not-quite symmetrical relationship. You can call get() as many times in a row as you like, but for print() you have to throw in a puts() for a space. The space between top-level objects may be necessary, and certainly makes sense when you think about it, but it *is* somewhat inconsistent with Euphoria's otherwise sensible and easy-to-understand language design, IMO. This is not limited to the get()/print() pair of functions, either -- Jason Gade recently pointed out (11/12/1999; Subject: Euphoria features) that position()/get_position() have a similarly non-symmetrical relationship. Another (possibly imperfect) example which springs to mind would be the video_config()/text_rows()/graphics_mode() family of routines. In any event, for the immediate future, this is probably the best solution for the problem in question: global procedure put(integer fn, object data) print(fn, data) puts(fn, ' ') -- or '\n', either one will work end procedure This way, we have the symmetrically-paired routines get() and put(). This enables those who wish to perform multiple get() calls against a file to have a self-contained procedure to write their data out to that file, without forcing the users of print() to use up an extra byte. Hep yadda, Gabriel Boehme ---------- There are few things as convincing as death to remind us of the quality with which we live our lives. Robert Fripp ----------