Re: out of memory, even tho remembered nothing!

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


Well, anyhow, this fails to run properly also:

junk = gets(readfile) 
while sequence(junk) do 
  size += length(junk) 
  puts(1,sprintf("%d",size)&"\r") 
  junk = gets(readfile) 
end while 

This can be shortened slightly using a feature introduced in 4.0:

while sequence(junk) with entry do 
  size += length(junk) 
  puts(1,sprintf("%d",size)&"\r") 
entry 
  junk = gets(readfile) 
end while 

Execution of the loop always starts at entry, skipping the condition the first time through.

useless_ said...

And so i am still tripping over typecasting. To me, -1 is not a sequence, nor should it be TRUE. To avoid the horrors like this, the following convoluted while must be used:

junk = gets(readfile) 
while not equal(-1,junk) do 
  size += length(junk) 
  puts(1,sprintf("%d",size)&"\r") 
  junk = gets(readfile) 
end while 

Yes, I typically check for a sequence, since you only get an atom returned from gets() after you've read all of the file.

useless_ said...

If it's voteable, i vote for replacing "while not equal(-1,junk) do" with "while junk do".

Anyhoo, this is getting off my original point, and i am glad Matt is fixing the memory leak in gets().

Yeah, this is related to the long debated equals() vs = reform. But I don't see changing the truth value of atoms changing (the sequence as a boolean / truth value is more likely).

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu