Guards

Peter Michaux petermichaux at gmail.com
Fri May 27 13:43:38 PDT 2011


On Fri, May 27, 2011 at 1:24 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> On Fri, May 27, 2011 at 4:03 PM, Peter Michaux <petermichaux at gmail.com> wrote:
>> On Fri, May 27, 2011 at 12:55 PM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
>>> On Fri, May 27, 2011 at 1:59 PM, Peter Michaux <petermichaux at gmail.com> wrote:
>>>>
>>>> A minifier could, couldn't it?
>>>>
>>>> function foo(a::MyType) {}
>>>>
>>>> would be minified to
>>>>
>>>> function foo(a) {}
>>>
>>> These are not the same function at all.
>>
>> Why?
>
> Because foo(7) produces a TypeError in one, and |undefined| in the
> other (assuming that MyType isn't Number).

Yes but I was thinking of the use of guards as a debugging/development
tool. During development you can verify that foo is never called with
bad values. Then during production, those checks do not need to be
performed. By removing the debugging checks for production, this would
save wire and execution time.

Peter


More information about the es-discuss mailing list