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 5:16

>>154
Data structures represent things, the things those data structures represent are defined by sets of vocabularies (i.e. procedures) over that data structure.

The exact same data (structure) can represent a tree, a finite sequence (or list, whatever), a queue, a stack and even a computer program.

Given a vocabulary which defines a thing, when the procedures which are that vocabulary are defined over one data structure, they have different complexity characteristics than if they are defined over a different one (obviously).

Now, if you use ``list'' to mean finite sequence, then almost all data structures can represent a ``list'' (arrays, hash tables, linked lists etc.). It's useful to use ``list'' like that sometimes, but in this conversation it is clearly not, because it has caused you to make many mistakes as a programmer.

From this superior vantage point, sglib is correctly seen as a vocabulary over any type (or kind) of linked list in C. It may be a vocabulary of incredibly shoddily implemented algorithms, but what it attempts to do is give a set of procedures to use on linked lists of int, float, char, some_struct etc. which both treat them as some thing (e.g. stacks or finite sequences) or which give a foundational vocabulary for vocabularies at higher level in a stratified design.

So saying ``woah woah woah, hold on, there's no data structures in this library'' is not very intelligent. The data structure is assumed. It's a library over any datastructure which fits the bill.

Similarly: ``woah woah woah, hold on, length is O(n) here'' is especially invalid for the same reason. A length procedure is a procedure over (and partially defining) a finite sequence (what you and wikipedia call a ``list'', and in this case it may be useful to call it a ``proper list'' (as does the blessed and holy Hyperspec, praise be to the gang of five which delivered it unto us)). You can't do better than O(n) for ``length'' over linked lists. It's not possible. You can change the data structure (as you attempted) but then you've changed the data structure, and hence the implementation and characteristics of other procedures in your vocabulary over that data structure (which you also discovered).

So your problems with sglib don't seem to be with sglib, but with the very idea of using linked lists as a data structure!

Now, this is absolutely insane for many reasons, because linked lists are an excellent data structure, but it is important to know what you are actually unhappy with.

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