russell.leggett at gmail.com
Tue Jun 12 09:25:34 PDT 2012
On Mon, Jun 11, 2012 at 3:50 PM, Brendan Eich <brendan at mozilla.org> wrote:
> Irakli Gozalishvili wrote:
>> Sorry for not being clear about this. Here is a simplified example of the
>> https://gist.github.com/**2911817 <https://gist.github.com/2911817>
>> Also this is just a single particular example, but I expect there to be
>> more. I think what I'm
>> really asking for is a way to know if …rest is being used.
> Your code doesn't work on a function that uses arguments the old fashioned
> way, though.
> Yes, you can make ...rest affect .length and make a dispatcher that counts
> on that, but it's a just-so story and a hard case. Hard cases make bad law.
> If it really matters, we can provide better reflection facilities, but I'm
> pretty sure it doesn't occur enough to justify doing so now.
> So use the toString hack if you must and let's see if this use-case
> becomes hot.
I think this is a pretty creative snippet of code, but ultimately
unreliable for the reasons mentioned. It does bring up something else,
though, that I've avoided mentioning so far, which is pattern matching. I
haven't mentioned it because there is clearly a
it, and that never made it to harmony, but in light of this thread I
wanted to reiterate how useful it would be. It would not really help
function.length, but would address the real underlying problem that the
arity dispatcher is trying to tackle. In a language without overloading,
the ability to do pattern matching would be an excellent solution to a very
common problem. We already have destructuring, it seems like such a small
jump to pattern matching. Hard to tell from looking at the strawman why
that never made it. If its a matter or feature bloat, I would rate that
higher than some other things like default args or array comprehensions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss