6 ms·
I didn't downvote you, but your comment left me scratching my head. You made a statement without any explanation. Care to elaborate why imperative programming i
by rahimnathwani 10y ago
I didn't downvote you, but your comment left me scratching my head. You made a statement without any explanation. Care to elaborate why imperative programming is so bad here? Real-world contracts also use imperative style.
- jacquesm 10y agoThis code is very bad, without going into an exhaustive enumeration, case sensitive function names, variables with unclear scope all over the place and so on. That it's imperative code is something that I don't think is damning by itself but all the side-effects (including side effects based on a single bit in the name of a function) really do warrant the 'accident waiting to happen'.
- willtim 10y agoWhile personally I would prefer a functional approach, I take your point that a much more restrictive imperative setting would also be considerably better.
- nawitus 10y ago> case sensitive function names Are you saying that function names should be case-insensitive?
- jacquesm 10y agoNo, I'm saying that if function names are case-sensitive that you're an idiot if you use that feature to distinguish between two functions otherwise named identically with different (important) side effects. The fact that the parameter set is different implies auto completion by an IDE was probably partially to blame here (if you did it by memory you'd have gotten a wrong parameter count warning). Some language features you best not exploit if you want to write reliable and bug-free (to whatever extent possible) code. This is not a typo so much as it is a very poor choice of naming convention.
- kartickv 10y agoI'm not the OP, but I think they should be case-insensitive, if only to prevent errors like this. If you think otherwise, in what situation would it make sense to have two functions with names differing only in case? No upside, only a downside.
- jacquesm 10y agoCase sensitive is fine if you throw an error when someone tries to define the same name with different case.
- kartickv 10y agoThat gets us to 99% of what I had in mind, by preventing bugs like this one, but the remaining 1% is: why, then, generate an error when someone invokes a function while specifying a different case? If there's only one function, does the case matter?
- chii 10y agoreal world contracts are interpreted by a court of law, which have leeways that aren't afforded by a machanical interpreter.