View Single Post
Old 11-09-2007, 01:46 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Quote:
Right now I’m sort of reading about functional programming, <...>
Beware, "functional programming" is modern slang for the original "procedural programming". Sometimes also called "structured programming". Compared to these days the term "structured" is overdone, but 25 years ago it was the best thing, though it was soon clear that this alone doesn't suffice for industry-strength programming.
Furthermore, in most cases you are right. Only a few additions/changes follow:

Quote:
-a pure functional language doesn’t use state
Absolutely true. It doesn't have "properties" (earlier called "attributes") either!

Quote:
a state has to do with change, i guess with variables in other languages. for example, if "car = wheel +frame", and later on "car = horse + carriage" that is a state change?
No. The definition of a car has changed! So your example has to do with definition of the "car", not state

Here is an example of a state-change:
First: car_age_in_months = 100
Second: car_age_in_month = 500
As you can see, this car ALWAYS has an age and the age can vary. In case of "age" it can only grow. But take the income of a person: it can grow or schrink.
Here's another example:
First: car_has_antigravity_suspenders = TRUE
Second: car_has_antigravity_suspenders = FALSE
So this futuristic car may or may not have antigravity-technology built in, but the phenomena of "anti-gravity-suspendors" ALWAYS is an issue and can change in TRUE or FALSE (after an upgrade for example).

Quote:
these states are kept in black boxes as well and return a value that will ultimately convert to a function when to is connected to other functions?
This a way to do it, but by no means a must.
In object oriented languages (and object based languages like Visual Basic 6, or VBA) a state is usually protected (we call it "hidden"). To see the state the programmer needs to write a function (=method) to view the state as read-only. Call this system a "black-box system" if you will.

Quote:
here are to ways to evaluate functional code, strict, which i guess looks at every function gieven, and lazy, which updates only those functions that need to be updated. Fo instance, if there are ten functions connected together and the 7 function is given a new value that has nothing to do with the other 6 functions, only the 3 function that its output is connected to will update.
Yes, an important aspect in programming effciently these days for very large projects.
__________________
Valmont is offline   Reply With Quote