super return

Steve Fink sphink at gmail.com
Thu Aug 31 01:01:15 UTC 2017


On 08/29/2017 08:56 AM, Allen Wirfs-Brock wrote:
>
>> On Aug 28, 2017, at 12:29 PM, Sebastian Malton <sebastian at malton.name 
>> <mailto:sebastian at malton.name>> wrote:
>>
>> The outcome of this basically means "return from current context up 
>> one level and then return from there”.
>
> This would be a terrible violation of functional encapsulation.  How 
> do you know that the (e.g.) forOf function isn’t internally using a 
> encapsulated helper function that is making the actual call to the 
> call back.  You simply have no way to predict where returning from the 
> current context “up one” means.
>
I agree. I think this would be much better as

```js
function someThing(doWith) {
return doWith.map(elem => {
         typeCheckLabel:
         return elem * 2;
});

     come from typeCheckLabel if (typeof elem !== "number");
return "Not all are numbers" ;
}
```

:-)

(I agree with the encapsulation argument.)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170830/f12d440d/attachment.html>


More information about the es-discuss mailing list