Hacker News new | ask | show | jobs
by paddw 1070 days ago
I have no doubt English like syntax is a terrible idea but this seems like a surprisingly readable example.
1 comments

Agreed, I rather like this line of code, but I must admit that the C-like version is perhaps better:

    sales_tax_amount = balance * state[42].tax_rate;
(Assuming I've guessed the meaning of the Cobol correctly - perhaps that's the rub.)

(ETA: Added semicolon.)

(ETA2: Fixed critical indexing bug.)

You forgot the semicolon.

Note the semicolon is significant. Barbaric, I know.

I think indexes start at 1 in COBOL. I had to look it up though. (aiui, they're called TABLEs and the index can start from any number)

So that'd be state[42].

Not all heroes wear capes.

I've put in a PR to upstream. LGTM

    #define MULTIPLY sales_tax_amount = balance * state[43].tax_rate; //