david.hopwood at industrial-designers.co.uk
Mon Sep 15 20:12:30 PDT 2008
Mark S. Miller wrote:
> On Mon, Sep 15, 2008 at 7:28 PM, David-Sarah Hopwood <
> david.hopwood at industrial-designers.co.uk> wrote:
>>> Agreed that this proposal does not prevent this existing confusion.
>>> Neither does it make it worse. If there's something we can plausibly
>>> do to fix this, I'd love to! Any suggestions?
>> The problem here is the lack of any run-time type distinction between
>> constructors and other functions. I don't see how to fix the existing
>> confusion in a compatible way. However, when we add the class feature in
>> ES-Harmony, we should avoid making it worse by using a desugaring that
>> allows the class name to be used with 'new', but prevents any use as a
>> function from breaking object encapsulation.
> The desugaring I presented in "Look ma, no 'this'"
> does so, precisely because it avoids 'this'.
Yes, so it does.
If we choose any other desugaring (perhaps using 'this' for performance
reasons, say), we should make sure that it retains that property.
When you ask for suggestions to prevent the existing confusion, do you mean:
- the fact that some built-ins have different specified behaviour when
used as functions vs as constructors, and this can't be expressed by
self-hosting code in all cases?
- the fact that something intended as a constructor can be called as
a function and vice-versa?
More information about the Es-discuss