Why data structure is just syntax sugar in FP
When I start to learn programming language. I hear the concept that “Closure is data and data is closure. They are just the two sides of the same coin”. I know it is quite plausible, but how can it be?
Since I wrote JS at that time, I started to think how to represent the map(object) and list by using function closure in JS. Unfortunately, I don’t have solid background knowledge in programming language and make no success.
However, after I read SICP, my mind is blowing up and this long time puzzle is finally resolved. Now I will just show you some code, and I believe you will understand it thoroughly by just taking a look.
See, we don’t need any data structure syntax, and we still can trap data in our code! However, most FP languages still implement data structure for performance or convenience reasons.
Good, when someone told you that “Data structure is just syntax sugar”, you will not be surprised for that!
