mlhaufe / brevity

Brevity is a library that enables Feature-Oriented Programming (FOP) and solves the expression problem in a manner that makes data and operation declarations trivial to define and compose.
GNU Affero General Public License v3.0
1 stars 0 forks source link

Replace `[all]` with `_` #34

Closed mlhaufe closed 1 year ago

mlhaufe commented 1 year ago

Given that a Data declaration requires variants to be ProperCase, _ can be used in Trait declarations without ambiguity:

const fib = Trait(undefined, {
  [all]: (n) => n == 0 ? 0 :
                n == 1 ? 1 :
                fib(n-1) + fib(n-2)
})

becomes:

const fib = Trait(undefined, {
  _: (n) => n == 0 ? 0 :
                n == 1 ? 1 :
                fib(n-1) + fib(n-2)
})