Urban75 Home About Offline BrixtonBuzz Contact

java script is verbose, discuss

Sunray said:
Thats fairly unreadable isn't it. I much prefer the code in the original post.

That's work in progress. What I'd actually use would be what I put a few posts later in post 11.


You might prefer the original code - but wait until you've actually tried maintaining code where the numeric array keys are explicitly defined. Trust me, it's a pain in the arse.

I used to be head of IT for this law firm in the city - they had this bespoke document management system where (among other things) numeric keys were explicityly defined like this - every time a member of staff left it would take about 1/2 a day going through the thing renumbering everything... and if you're doing that amount of stuff by hand, there will always be typos.
 
laptop said:
Can't be arsed to work out what that does - but I'm sure it'd be easier to read in assembler? (Even with conditionals for cross-platform compiling/assembly.)

Its exercise 2-6 in k&r

Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position p set to the rightmost n bits of y, leaving the other bits unchanged.
 
Back
Top Bottom