On Mon, Feb 19, 2018 at 9:25 AM, T.J. Crowder <
tj.crow...@farsightsoftware.com> wrote:

> On Mon, Feb 19, 2018 at 1:59 PM, Александр Ефремов <mr.ef...@gmail.com>
> wrote:
>
> When [decorators][1] land, provided they land with a means of [decorating
> functions][2] (either as part of that proposal or as a follow-on), that
> would do the job, wouldn't it? Using your `sum` example:
>
> ```js
> @rttc(PrimitiveNumber, PrimitiveNumber)
> const sum = (a, b) => {
>     return a + b;
> };
> ```
>
> ...where `rttc` ("runtime type check") decorates the function such that it
> does runtime validation of the type of the arguments supplied. (See the
> issue referenced in the second link above for why I used a function
> expression rather than declration for `sum`.)
>

+1 for a single mechanisms that enables not just preconditions, but
postconditions.

Decorators could also make it super-easy to do things like deprecation
warnings and memoization a la python [1]

[1] https://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to