Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There are three data structures unsystematically blended into one (that is, one cannot unambiguously tell which fields go into which "virtual" type, and cannot formally check the correctness). The name thing_t is indicative that you indeed cannot really tell what that entity is. This kind of data structure design begs for errors, while being conceptually wrong.


> There are three data structures unsystematically blended into one

The point is that they're not three completely separate data structures, they're a single data structure with context-dependent field labelling.


I get your point, but how to tell "labelling" from typing? Typing depends on semantics. This particular example only works out because the types are all strings, which is a case of sort of loose typing often used in programming. It could've been like this:

  typedef struct {
	union {
		company_t * company;
		school_t * school;
		project_t * project;
	};
	union {
		address_t * location;
		url_t * url;
	};
etc.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: