Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #23567

Re: class needs to initialize vars, set data structure

Message-ID <1518416.lQCqFX8JqD@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2014-03-12 11:46 +0100
Subject Re: class needs to initialize vars, set data structure
Newsgroups comp.lang.javascript
References <972c7156-b68b-4ff4-8d82-55f00676b1a7@googlegroups.com> <return-20140312004838@ram.dialup.fu-berlin.de> <0.22105c4cd91aee1e4818.20140312031736GMT.87y50gjeb3.fsf@bsb.me.uk> <brace-20140312110935@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram wrote:

> Ben Bacarisse <ben.usenet@bsb.me.uk> writes:
>>> var Set = function()
>>> { var map = {};
>>>  return
>>>  { add     : function( element ){ map[ element ]= true; },
>>>    remove  : function( element ){ delete map[ element ]; },
>>>    contains: function( element ){ return map.hasOwnProperty( element );
>>>    },
>>>    count   : function( element ){ return Object.keys( map ).length; }}};
>>>
>>>  (The »error« with the brace after the return is intended.
>>>  I will not allow JavaScript to dictate my bracing style!)
>> So what do you do?  Do you sit and admire it, or do you have an
>> implementation that can run it?
> 
>   I made a note once that reads:
> 
> return \
> { ...
> 
>   , and I remember that this did work somewhere,

Not in any ECMAScript implementation I have come across within now 17 years 
of experience.

A remote possibility is that this was part of a /Program/ evaluated with 
eval(), in which case it could have worked if the implementation supported 
what ECMAScript Edition 5 (2009) now specifies: multi-line string literals.

  eval("function f () { return \
{}; }");

Of course, both eval() and this notation is to be avoided.

<http://PointedEars.de/es-matrix?filter=%5C>

>   but now it turned out it does not work in my browser.

Apparently you have yet to take the important step in the learning curve of 
thinking in terms of implementations instead of in browsers.

>   However, when my published program still contains errors, I
>   do not risk the accusation of doing other people's homework!

Or you could be considered a wannabe/troll.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

class needs to initialize vars, set data structure JRough <janis.rough@gmail.com> - 2014-03-11 15:36 -0700
  Re: class needs to initialize vars, set data structure Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-12 03:34 +0100
    Re: class needs to initialize vars, set data structure Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-12 15:09 +0100
    Re: class needs to initialize vars, set data structure John Harris <niam@jghnorth.org.uk.invalid> - 2014-03-12 17:04 +0000
      Re: class needs to initialize vars, set data structure John Harris <niam@jghnorth.org.uk.invalid> - 2014-03-14 10:48 +0000
  Re: class needs to initialize vars, set data structure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-03-12 03:17 +0000
    Re: class needs to initialize vars, set data structure Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-12 11:46 +0100
    Re: class needs to initialize vars, set data structure Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-25 22:51 +0200
      Re: class needs to initialize vars, set data structure Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-26 00:42 +0200
        Re: class needs to initialize vars, set data structure Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-06-26 11:16 +0200
        Re: class needs to initialize vars, set data structure Christoph Michael Becker <cmbecker69@arcor.de> - 2014-06-26 21:44 +0200
          Re: class needs to initialize vars, set data structure John Harris <niam@jghnorth.org.uk.invalid> - 2014-06-27 09:46 +0100
            Re: class needs to initialize vars, set data structure Scott Sauyet <scott.sauyet@gmail.com> - 2014-06-28 21:57 -0700
  Re: class needs to initialize vars, set data structure Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-12 15:34 +0100

csiph-web