Re: out of memory, even tho remembered nothing!

new topic     » goto parent     » topic index » view thread      » older message » newer message
eukat 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 


I just tried this, and it appears to work correctly for me. It gets the number of bytes in the file and reports it correctly, and then quits.

What behavior is it exhibiting for you that causes you to declare that it has failed?

eukat said...

I looked in io.e for what EOF is when gets() hits the end of the file:

From docs on gets() -

Returns: An object, either EOF on end of file, or the next line of text from the file.

and from io.e -

public constant EOF = (-1)

You already know this, but just so other readers of this thread are clear: gets() returns a value that is equal to the public constant EOF in io.e, but it doesn't actually use that constant. It merely returns -1.

eukat said...

And so i am still tripping over typecasting.

I don't see how.

eukat said...

To me, -1 is not a sequence,

Agreed. When I run your code, it seems to confirm that this is the case (that -1 is not a sequence).

eukat said...

nor should it be TRUE.

I disagree. -1 should be TRUE since -1 is the set of bits such that all bits are equal to 1.

eukat said...

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 


Avoid horrors like what? Why must this be used, instead of your original code above?

eukat said...

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

Same here. I'm sure we could enhance the parser so that, if gets() is being called inside an if or while statement (or something akin to that) it returns 0 on EOF instead of -1, as well as making any sequence from gets() counted as a TRUE value.

I'd hate to see -1 become a FALSE value, though.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu