Re: I don't like the intro page of the documentation.

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

IIRC there is a case, new to 4.0, where this is not true any longer. That is with autopromotion - when you attach a delete routine to an integer, it is promoted into the full floating point format (and thus taking up all that extra space) so it can safely store the information for the delete routine - even though the actual value would otherwise fit into a normal integer. std/eumem.e is affected by this.

Yes, this was the main thing I was thinking of, but I think there are other cases where a calculation result would be demoted if stored into an integer variable. For instance:

atom x 
integer y 
object z = 2.5 
x = z - 0.5 
y = z - 0.5 
? x & y & z 

You can perhaps see this happening most easily by translating. The key part is this:

 
    /** bug.ex:7	y = z - 0.5*/ 
    _1y_170 = NewDouble(DBL_PTR(_1z_171)->dbl - DBL_PTR(_9)->dbl); 
    if (!IS_ATOM_INT(_1y_170)) { 
        _1 = (object)(DBL_PTR(_1y_170)->dbl); 
        DeRefDS(_1y_170); 
        _1y_170 = _1; 
    } 
jimcbrown said...

(Regex works similarly, though on 32bits the values would be addresses requiring a full atom anyways.)

Yes, except that regexes are sequences to begin with, so the only difference is the extra bit of metadata for regex cleanup.

jimcbrown said...

I think this applies even if the variable is explicitly declared as an integer rather than an atom.

If you store an atom with a delete routine as an integer, the actual atom created will only be stored in a temp, and it will go away because the integer does not hold onto a reference. Simple demo:

procedure its_gone( object o ) 
	printf(1, "cleaning up after %d\n", o ) 
end procedure 
 
integer foo = delete_routine( 1, routine_id("its_gone" ) ) 
puts(1, "after foo...\n") 
 
atom bar = delete_routine( 2, routine_id( "its_gone" ) ) 
puts(1, "after bar...\n" ) 
bar = 0 
puts(1, "bar is gone...\n") 

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu