Proposal to add symbol: "hasInstanceStrict"
Mike Samuel
mikesamuel at gmail.com
Mon Feb 19 16:30:58 UTC 2018
On Mon, Feb 19, 2018 at 9:25 AM, T.J. Crowder <
tj.crowder at farsightsoftware.com> wrote:
> On Mon, Feb 19, 2018 at 1:59 PM, Александр Ефремов <mr.efrem at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180219/4bed1132/attachment.html>
More information about the es-discuss
mailing list