4 ms·
> If by fairly wide-adopted you mean it is adopted in a handful of language nobody uses, sure. Please precisely define your criteria so that I can end this dis
by valenterry 2y ago
> If by fairly wide-adopted you mean it is adopted in a handful of language nobody uses, sure.
Please precisely define your criteria so that I can end this discussion by giving you a concrete counter example.
> That is just "if" by another name!
It appears you haven't understand the difference. Here's a counter example:
let first_result = divide(10, ???);
let second_result = divide(20, ???);
let final_result = first_result.or(second_result).unwrap_or(42);
println!("Result: {}", final_result);
Logic being, do two divisions and print the result of the first one, or if it failed, of the second one, or fall back to 42.
We can go one with using lists of results, results of results and doing conditional calculations and so on and so on - and all of that without writing a single if.
Now do that in go without using if. Won't look as nice for sure.
- 9rx 2y ago> Please precisely define your criteria You introduced the term. It is on you to define it. My stab in the dark to try and get us to an understanding may have failed, but that's where you would logically come in and explain yourself in better detail. > so that I can end this discussion by giving you a concrete counter example. A single counter example? I definitely would have never guessed that by wide-adoption you were thinking something singular. No wonder you've been so afraid to share your definition. > Logic being, do two divisions and print the result of the first one, or if it failed, of the second one, or fall back to 42. That too is just "if" with different syntax, and worse syntax – treading into Perl one-liner territory, but I concede that this particular example may not be a good basis on which to start from.
- valenterry 2y agoOkay then, how about "at least 3 languages with each at least a few thousand devs using them supports it" And my example is not "if". There is no if. Maybe there is "if" being used in the underlying functions? Again, eventually everything is machine code, but then every discussion about PLs is meaningless...
- 9rx 2y ago> And my example is not "if". There is no if. It doesn't literally include the keyword "if", but you've only rewritten an "if" statement in different syntax – and with worse syntax at that. It doesn't take things to a higher level. But, again, I understand that this is probably not a good example on which to start from. We only ended up with it because it is a common snippet found elsewhere. How about you pick something that is a better demonstration? > Again, eventually everything is machine code Right, but we have higher level languages that enable expressing ideas beyond what the machine is directly capable of. The "if" statement itself is one such abstraction, albeit a fairly low-level one.
- valenterry 2y ago> but you've only rewritten an "if" statement in different syntax I don't understand what you mean. There is, to my knowledge, no different syntax for if-statements. In my code example there simply is no if being used. Care to elaborate?
- 9rx 2y ago> There is, to my knowledge, no different syntax for if-statements. Can we agree that the ternary operator in C provides a way to write if-statements with different syntax? > In my code example there simply is no if being used. Assuming we do agree, there is no literal "if" being used when using the ternary operator. However, it doesn't take the concept to a higher level. It is still leans on the exact same conceptual if-statement expression, albeit written in a slightly different way. The same is true of your code example.
- valenterry 2y ago> Can we agree that the ternary operator in C provides a way to write if-statements with different syntax? I can neither agree or disagree because I don't know, but we are not talking about C and my code example didn't use a ternary operator either, so from my POV it doesn't matter. > async/await was a better example. That moves something to a higher level of abstraction. However, it is not clear how to make that generalize It is clear. Just not to you. Check Haskels do-notation or Scala for-comprehension or F#'s do!-notation and how they work. They all generalize over what async/await does (all with slightly different syntax though)