Skip to content

Commit 6d56e78

Browse files
committed
Simplify Scala implicits section
1 parent 0dab876 commit 6d56e78

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

blog/2026-02-28-v0.7.0-release.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,10 @@ impl AreaCalculator {
334334

335335
The word "implicit" may raise a flag for developers familiar with Scala's implicit parameter system — a feature with a well-documented reputation for producing confusing errors, ambiguous resolution, and code that is hard to trace. It's a fair concern, and it deserves a direct answer: CGP's `#[implicit]` attribute shares the same surface-level motivation as Scala implicits (reducing boilerplate at call sites), but the underlying mechanisms are categorically different in the ways that matter most.
336336

337-
**Resolution scope.** In Scala, the compiler searches a broad, layered *implicit scope* that spans local variables, companion objects, and imports — meaning an implicit value can materialize from almost anywhere. In CGP, `#[implicit]` always resolves to a *field on `self`*, and nowhere else. There is no ambient environment, no companion object search, and no imports to reason about.
337+
**Resolution scope.** In Scala, the compiler searches a broad, layered *implicit scope* that spans local variables, companion objects, and imports — meaning an implicit value can materialize from almost anywhere. In CGP, `#[implicit]` always resolves to a field on `self`, and nowhere else. There is no ambient environment, no companion object search, and no imports to reason about.
338338

339339
**No ambiguity.** Scala's type-only resolution means two in-scope values of the same type create an ambiguity that requires explicit disambiguation. CGP resolves by *both name and type*: `#[implicit] width: f64` looks for a field named specifically `width` of type `f64`. Because Rust structs cannot have two fields with the same name, CGP implicit arguments are unambiguous by construction.
340340

341-
**No propagation.** Scala's implicit requirements climb the call stack — any function that calls an implicit-consuming function must either declare the same implicit parameter or supply the value explicitly. CGP has no such propagation. The `HasField` bounds generated by `#[implicit]` appear in the provider's `where` clause and are fully encapsulated there. Callers see only the consumer trait; they never need to know which fields the implementation reads internally.
342-
343341
**Transparent desugaring.** Every `#[implicit]` annotation expands mechanically into a `HasField` trait bound and a `get_field` call — ordinary Rust constructs that any developer can read and verify. There is no hidden resolution phase, no special compiler magic, and no "implicit hell" accumulation risk.
344342

345343
## New area calculation tutorials

0 commit comments

Comments
 (0)