wmorgan comments on Automatic programming, an example - Less Wrong

12 Post author: Thomas 01 February 2012 08:55PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (32)

You are viewing a single comment's thread. Show more comments above.

Comment author: Thomas 02 February 2012 05:28:46PM *  2 points [-]

No. The posted code has a bit shift right for 12 places. The already optimized code by wmorgan has a bit shift for only 10 bits.

The metacommand $RESCOM if while val_operation inc_dec caused this. Having two constants (10 and 12) would be undesirable be cause of this "val_operation" and therefore only the constant 12 was used.

Comment author: wmorgan 02 February 2012 07:18:41PM 1 point [-]

This is the generated code segment:

aphelion=aphelion+aphelion;
aphelion=aphelion+aphelion;
guess=12;
aphelion=aphelion>>guess;

Those four lines together amount to a shift 10 bits to the right, i.e., division by 1024.

I think you understand what's going in the code. The point of my refactoring was to make something that was human-readable: something that I could describe in English. And the English for those four lines of code is "divide by 1024." That's what those four lines do.