-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ary Borenszweig edited this page Aug 4, 2015
·
17 revisions
Apart from the "Crystal has Ruby-inspired syntax" reason, there are more reasons:
- If you copy and paste a snippet of code, you have to manually re-indent the code for it to work. This slows you down if you just wanted to do a quick test.
- If you want to comment some code, for example comment an
ifcondition, you have to re-indent its body. Later you want to uncomment theifand you'll need to re-indent the body. This slows you down and it's cumbersome. - Macros become harder to write. Consider the json_mapping macro. It defines
defs, usescase ... when ... else ... endwithout having to bother whether the generated code will be indented. Withoutend, the user would have to correctly indent the lines that would be generated. - If you want a template language like ERB or ECR for a language that doesn't care about whitespace, you'll have to put those
endto signal where conditions/loops/blocks end. - Right now you can do:
[1, 2, 3].select { |x| x.even? }.map { |x| x.to_s }. Or you can do it withdo .. end. How would you chain calls in an indentation-based language? Usage of{ ... }is not valid, only indentation should be used to match code blocks. - Assuming one day we have a REPL, in which you tend to write code quickly, it's tedious and bug-prone to match indentation, because whitespace is basically invisible.
Because of all the above reasons, know that the end keyword is here forever: there's no point in trying to suggest changing the language to an indentation-based one.