|
I've never looked at CLOS. But, what I mean is the "dominant metaphor," which I suspect is still lists. I'll just go through my probably plebeian understanding. Arrays are to lists as hashtables are to objects. An array, in my mind, is a list that only contains one type and is indexed with enumerated integers. On the other hand a list can contain any type, but is also indexed with enumerated integers. In JavaScript: array = [1, 2, 3]
list = ["one", [[array], 3]]
array[0] == 1
list[20] = 23 // list indices aren't necessarily a linear enumeration
Of course, arrays and lists are both technically Arrays in JavaScript (a bad naming choice; I'd have called them Lists). Now a hashtable is typically just a list that uses strings for indices instead of integers. hashtable = {
"today":20080403,
future:function(x) { return this.today + x }
}
A "method" is just a value that happens to be a function. Usually hashtable-oriented languages choose to abstract away the string, and treat it as a variable. hashtable["today"] == hashtable.today
hashtable.method(23)
Like with lists/arrays, JavaScript gets hashtables/objects almost exactly right, but again is subject to some questionable naming choices.RE: trees and graphs -- I was getting at the relationships between nodes, not the actual computations, but I'm not comfortable enough with the terminology to explain exactly what I meant. |
It's a fun thread :D