lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mar 25, 2014, at 12:39 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

>> The important thing is that algorithms implemented in other languages
>> should be straightforwardly portable. Having an algorithm that needs
>> changed for Lua and Lua alone is the violation of the principle of
>> least surprise.
> 
> This would also be a good argument. Can you give concrete examples
> of algorithms implemented in other languages that would be
> straightforwardly portable to Lua except for the logical shift?  (That
> would also provide examples of the usefulness of the arithmetic shift.)
> 
> -- Roberto
> 

Well for me some years ago I had to code up a (very) fast CCITT group 3 fax decoder that needed to handle a huffman compressed token stream .. with tokens varying in length from 3 to 13 bits. Lots of shifts and masking involved here, which were table driven by shift factors all over the place. Transcoding that (from C) to Lua without shifts would involve working though all the tables replacing the shifts with powers of two factors, then searching out all functions that had shift factors as arguments etc. Certainly more work than would be involved if Lua had shift operators. That said, for this project I cannot recall needing arithmetic shift, just logical.

I would suspect the large corpus of crypto code makes heavy use of shifting also.

—Tim