码迷,mamicode.com
首页 > 其他好文 > 详细

Free symbol is Harmful

时间:2014-08-21 19:11:34      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:des   style   os   io   strong   for   ar   div   

What is Free Variable?

  "Free" is relative to "Bound"。Function parameters are "bound" to a function; Local variables/functions/classes are "bound" to a function. A variable which is defined out of a function is "free" for this function.

 

Why is Free variable harmful?

  Free variables make a function depend on outside scopes. When a programer reads a function with some free variables, He/She has to go to the definition of a free variable to see what it means. Furthermore, He/She will worry about whether there are other operations on this variable at somewhere else.

   Personally, in terms of programming, I would rather to know what a function does, explicitly from the parameters I give it. Read/Write operations of free variables inside a function are indeed implicit operations, which is like undercurrent water, you never know how it flows(unless dive in to read through all the codes).

 

Functional programming cuts down Free variables

  Most functional programming languages do limitations on variable assignment(Side Effects). Although I think it‘s a "Hypercorrection", It does cuts down free variables. In functional programming, functions are much like state transformations, which is quite direct and expressive.  Data flows are quite direct and expressive in this way.

Free symbol is Harmful,布布扣,bubuko.com

Free symbol is Harmful

标签:des   style   os   io   strong   for   ar   div   

原文地址:http://www.cnblogs.com/linghuaichong/p/3915357.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!