1. Re: optimization

Andy Kurnia suggested instead of:

>>        c = fn
>>        while c != -1 do
>>                c = getc(fn)
>>                r = r&c
>>        end while

to use:

> if fn != -1 then
>     c = getc(fn)
>     while c != -1 do
>         r = r & c
>         c = getc(fn)
>     end while
> end if

That used to be my approach, until I saw Robert's example in the manual for
'gets'. His logic is more like:

while 1 do
   c = getc(fn)
   if c = -1 then
      exit
   end if
   r = r & c
end while

So I assume this is the "preferred" idiom.

-- David Cuny

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu