jll63 / openmethods.d

Open multi-methods for the D language. OPEN! Multi is cool. Open is great.
44 stars 8 forks source link

simplify declaractions #2

Closed John-Colvin closed 7 years ago

John-Colvin commented 7 years ago

Don't want to allocate runtime space in TLS (or anywhere else) for IsVirtual, so change to enum

static isn't doing anything on CallParams

jll63 commented 7 years ago

IsVirtual is used only a compile time. But indeed I saw in the std lib code that they use enum for this sort of things. static: dunni remember why, maybe I initially nested this class into another?? Regardless, thanks for the patch.

PetarKirov commented 7 years ago

@jll63 as a rule of thumb, if something is only needed at compile-time, always use enum. If the result would be used more than once at runtime, use static immutable, which in addition to what enum gives you (forcing compile-time evaluation) will store the literal as a global variable, so that multiple uses at runtime would not cause re-evaluation. See also: http://dlang.org/blog/2017/06/05/compile-time-sort-in-d/