RE: three stupid newbie questions :-)
- Posted by Andy Serpa <ac at onehorseshy.com> Jan 20, 2004
- 462 views
Pete Lomax wrote: > > > On Mon, 19 Jan 2004 10:53:25 -0800 (PST), Guest > <guest at RapidEuphoria.com> wrote: > > >posted by: shenpen at freemail.hu > > > >while not atom(line=gets(filehandle)) > The inner compare is a sequence operation: if both lhs and rhs are > atoms it returns pretty much what you might expect, if one is an atom, > it compares that against all the elements on the other side, if both > are sequences, they must be the same length or it stops with a fatal > error. If the lhs and the rhs are same size/shape tree then you get > back a same size/shape tree filled with 1's and 0's. FWIW I don't > think that is particularly useful and would vote to change it, but it > is a fairly core concept in the language. > I don't think he meant it as a compare at all [ line = gets(filehandle) ], only as an assignment, and Euphoria doesn't allow those type of assignments. Regarding the usefulness of the Euphorian-style sequence comparison -- I couldn't go without it. Makes my code at least 50% easier to write than it would be otherwise. Love it. I'm lobbying for the conditional operator to make it even easier... > You have to use either: > > while 1 do > line=gets(filehandle) > if atom(line) then exit end if > The solution is the same, however. > Or: > > function setline(object x) > line = x > return x > end function > > while not atom(setline(gets(filehandle))) do > I like the first is better. Avoids the global.