Is `keyword_argument = Val{true}` good practice or an antipattern?

Krastanov
Mon, 31 Jan 2022 21:26:19 +0000
General Usage

I am seeing more and more library code that is written with keyword arguments of the form kwarg = Val{true} instead of kwarg = true or even kwarg::Bool = true. I know this is done in order to force specialization in precompilation which drastically improves time-to-first-X. However, I can not shake the feeling that it is plain ugly, a legibility sacrifice for a performance idiosyncrasy in Julia (that hopefully would be fixed in the future). After all, we all want a magically fast language that is as expressive as the slow magically dynamic language (I acknowledge that creating the magic is a monumental effort).

I would be grateful to hear from more advanced users of the language how they feel about this style.

20 posts - 8 participants