Hacker News new | ask | show | jobs
by MauranKilom 1757 days ago
Random example: In geometry code, you might distinguish between points and vectors, where point + vector = point, point - point = vector etc.

It can then also be convenient to have a special type/value Origin, which (while functionally identical to point(0, 0)) allows you to e.g. write vector = point - origin to clearly express your intent of turning a vector into a point.

-1 * origin is not meaningful, but point - origin is (while point + origin is not).

1 comments

But in this case I don't think you're working on the standard field. I mean you're working in different coordinates. I do understand that the example only works in R1 space with standard addition, but that's kinda the point of my question. That the "error" isn't really an error unless you're being pretty pedantic.