Hacker News new | ask | show | jobs
by gugagore 2556 days ago
I thought about using `[]`or `indexOf` as examples of operations, but my question still remains: what is implicit about it? It's part of the public interface of `List`.

Not at all like the private members of an object, which I think was the analogy being made.

2 comments

Those aren't implicit because the "public interface" is the Object List, not the Data Structure List.

    struct list {
      float node;
      struct list *next;
    }
Above is the data structure; it implies operations. Below is an interface (class, in the article); it implies data.

    #define LIST_H
    
    float index(struct list *ls, int i);
    int find(struct list *ls, float x);
    void sort(struct list *ls);
I think the point is that the data structure implies that there must be some operations to create and examine it. If there is no operation to create it, how did it come to exist? If there is no operation to examine it, then how do you know it's there at all? To go all Zen koan on it: if a data structure cannot be examined or changed, then is it really there at all?

That said I don't think that any particular set of operations is implied. A data structure will be more suitable for some operations than others, but it won't really require anything in particular.