Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

foreache

Name: Anonymous 2014-01-20 18:58

what is you're opinion on foreache loops?

i don't like em cuz they ache in the fore

Name: Anonymous 2014-01-24 6:30

>>155
No, my problems are with the view of data as irrelevant. Let us take the example of a collection of things, of a tree, of a directed graph, of any structure of data. It is completely unacceptable to carefully organize data in a program, then completely ignore this organization of data in the procedures for the program.

You say a data structure can represent many concepts. Certainly that is true. But it is used in a program to represent exactly one thing: what it represents. This may be a finite sequence, it may be a tree of a specified order, it may be a data which is built up as a planar graph, then evaluated as a function, then treated as a number. Whatever its role is, it is important within a program, and both data structures and procedures should be written with that role in mind.

It is foolish to implement the role of an array with a linked list. The strengths of a linked list are completely unused, the weaknesses will prove irritating. It is foolish to implement the role of a constant, fixed string with a hash table. It is foolish to implement the concept of a linked list using ... take your pick of unsuitable data structure. If you try, you can come up with alternate - but close - roles for each of those examples that are well met by that which I call ``unsuitable'', but to do so you'll have to re-specify the role, and my point is that the role matters.

Just so, it is foolish to write a function that, knowing the role and implementation of the data it will handle, ignores it. Why search through an array blindly if you know it is sorted?

I know the objections you'll make, so I'll address them. Concrete data structures, created without any specific role of data in mind, are good enough most of the time. Ditto for functions. They made a language based on that concept and called it Java; it's doing quite well. Most of the time, the roles of data in a program fit very nicely to common, well known, possibly built-in data structures. I'm not denying that at all. Programmer time is also a constraint. Perhaps it takes too long to write a perfect data structure, but a known, implemented data structure comes close enough. (But linked lists are not a data structure that takes too long to write.)

What I am saying is that the following situation is idiotic:

You are writing a C program, so you don't have very many complex structures pre-written at your disposal, so you decide to write some yourself. At this point, you pick up a set of predefined algorithms that only handle very basic, very generic data structures correctly, and you write those structures yourself, and only those structures. Indeed, let's consider two cases:

1) You are writing a program where a data role maps perfectly to a linked list
2) You are writing a program where a data role maps to something that is not a linked list

In case 1, this library doesn't make sense, because it could have trivially defined the structure of the linked list it expects for you.
In case 2, this library doesn't make sense, because you don't need ``a foundational vocabulary for vocabularies at higher level in a stratified design''. You're already writing the data structures and vocabularies for all levels of design. If you want a linked list with extra parts bolted into the storage (think a skiplist), these foundational vocabularies don't handle the extra table of links and so won't work properly. If you want something that can be emulated by linked lists (perhaps a tree of some sort), there will be restrictions put on those linked lists that can't be exploited, because they aren't known about.

That is my complaint. The only way for this library to be useful is either if you have a very clean use case (in which case the library is trivially deficient), or if you are ignoring the role of your data. Data is not irrelevant. It is a programmer's job to craft structures and procedures to handle it, and there is no part of that task that this library helps.

Yes, you can implement any kind of data structure using linked lists as the base. You can also do it using arrays, sets, strings, hash maps, etc. Please stop telling me how wonderful linked lists are. I know what you can use them for, and I also know that they are not the only structure that can fill that role. I'm saying that in the only situations in which this library would be used, using linked lists like that is a bad idea.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List