A streamlined non-disturbing class possibility

Rick Waldron waldron.rick at gmail.com
Tue Jan 31 08:50:09 PST 2012


Similar discussion here:

http://www.mail-archive.com/es-discuss@mozilla.org/msg10692.html



On Tue, Jan 31, 2012 at 5:18 AM, Herby Vojčík <herby at mailbox.sk> wrote:

> With .{...} around, I wonder, do we really need special class construct
> with its own structure? I think with a little set of changes, minimal,
> well-blended solution would be possible:
>
> 1. Allow <| for function declarations.
>
>  SuperFun <|
>  function fun(...) {
>    ...
>  }
>
> 2. Allow .{} for function declarations.
>
>  function gz(compress=false, blob) {
>    ...
>  }.{
>    GZIP := 2,   // := is const member as in actual proposal
>    DEFLATE := 4
>  }
>
> 3. Define keyword 'class' to do exact same thing as function (declare
> function or return expression; setting up empty prototype and constructor
> property in it), with only one difference - it's completion value will be
> the prototype, not the constructor.
>
>  Animal <|
>  class Fox (...) {
>    // instance initialzation
>  }.{
>    // instance-shared behaviour (aka prototype)
>  }
>
>  Fox.{
>    // optionally some static ones
>  }
>
> Class-private is the only hard thing. Well, I'd be able to live without
> it. Just put a private keyword before the class declaration. No big issue,
> if you want to reuse later, you will, if not, you will not; just don't
> export it; it will be local to the scope in which class was defined, it may
> be enough.
>
> Herby
> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120131/9d34bef9/attachment.html>


More information about the es-discuss mailing list