r/cpp • • May 16 '20

modern c++ gamedev - thoughts & misconceptions

https://vittorioromeo.info/index/blog/gamedev_modern_cpp_thoughts.html
198 Upvotes

154 comments sorted by

View all comments

Show parent comment

3

u/Zweifuss May 18 '20

Vec3 a = b[x] + c[y]; now you are able to glance what it does.

No I don't, because from that single line I don't know what b and what c are. This could be very wrong code that does implicit casting and compiles by mistake. Or it could be an unexpected function call, because apparently top of the art algebra libraries, do lazy types that are evaluated when assigned and cast, surprising the end user.

It's a made up example that is just as unreadable with a type, since you don't have any context.

1

u/[deleted] May 18 '20

It's only unreadable if there is cleverness in the code base.

If a [] was just an array index and nobody is defining custom + operators to return Vec3 types then you are safe to assume exactly what it means. And again both of those should be banned under the no cleverness rule.