Why don't Scala traits allow constructor parameters? -


i'm new scala, coming java, , reading traits. 1 thing gets mentioned traits don't (can't? won't?) have constructor parameters. curious know if there reason this.

coming long ago maths/computer-science background was wondering if inevitable consequence because of language design decision, or if conscious decision avoid inheritance/mix-in problem or another?

was hoping might know because feels there might interesting behind fact.

the other answers describe language; suspect question may "why designed in way".

i believe arises out of awkwardnesses , verboseness arise when extending multiple traits, overrides , types, , various mix-in strategies.

the cake pattern results in various traits providing missing bits each other in way totally invisible - design - in mixing class. , mixing can bi-directional, using self-types. construction of class traits can messy business compiler. scala trades simplicity of compiler design , implementation simplicity of language use , code reduction, , example.

so while there may simple, hierarchical cases having constructor might useful , sufficient, have redundant of other mechanisms more difficult, non-hierarchical scenarios.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -