I tend to use âthis isnât explicit and explicit is goodâ, so I feel compelled to explain what I mean by explicit, since itâs not represented in the post. Note, I canât think of another word which makes my notion more clear.
My notion of implicit vs explicit is mostly influenced by things in C++ which are implicit vs explicit, like coersions and conversions. For example, single argument constructors can be marked as explicit, which means that they arenât considered in contexts where implicit conversions are allowed but explicit ones are.
So, how does one apply this to Rust?
As an example, constructors in C++ both âconstructâ and âconvertâ, unless the user types the keyword âexplicitâ with the declaration. The relevant take away here is that a choice is being made (i.e. to âconvertâ or not) but the choice is defaulted without the user needing to acknowledge that a choice has been made. Another example is const in method declarations (struct S { void foo() const; };. Note, lambdas are similarly implicit but change the default, so you need [a]() mutable { a = 10; } if you want to capture a by value and then change it (note, this wonât change the original value of a).
So, when I say, âthis syntax isnât explicitâ, what I really mean is that a choice is being made (because itâs defaulted) and the programmer is not required to type or read something which acknowledges this choice.
So, as an example in Rust, if I type mod s { struct S; }, then S is not public and I may not even know that Rust has a public vs private distinction. In this case, even though this syntax is implicit, it is mostly fine because users will eventually get an error when trying to use S and will learn the syntax anyways.
Rust mostly gets this right and implicit features have defaults which are more restrictive and therefore, users only need to type more and learn more about various choices when they need to.
Anyways, this is the most useful definition of explicit/implicit Iâve encountered, because it allows reasoning about whether code (as read, after the fact) was written to intentionally do something or not.