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


Groups > comp.lang.javascript > #30253

Re: Comparing some of the ways to create objects

From Scott Sauyet <scott@sauyet.com>
Newsgroups comp.lang.javascript
Subject Re: Comparing some of the ways to create objects
Date 2016-04-10 16:51 +0000
Organization A noiseless patient Spider
Message-ID <nee0b2$p9m$1@dont-email.me> (permalink)
References (6 earlier) <crgfgbd1s7r9irkgg6vbm7qt6e1e8a3ctd@4ax.com> <ne9go3$ehl$1@dont-email.me> <closures-20160409050628@ram.dialup.fu-berlin.de> <nebblk$6dj$1@dont-email.me> <closures-in-Java-20160409180237@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram wrote:
> Scott Sauyet writes:

>> Yes, I was gone from Java before version 8 was released, so I haven't
>> really played around with this all that much.  But it's interesting
>> because you answered a question a colleague and I were speculating 
>> about a few days ago, but weren't quite motivated enough to actually 
>> research.
> 
> The Java example I gave should run with every Java version since
> version 1.1 (1997).

Ah, you tricked me.  :-)  I saw unfamiliar-looking code, and assumed it 
was something new.  And since reading Java hurts my head (or my pride, 
sometimes I can't tell!), I didn't look any further.  But it was only 
code laid out differently than I'm used to.  Sorry.

The relevant part of the Java sample, when formatted so I can read it 
looks something like this:

|   static final Example closureGenerator(final java.lang.Integer i) {
|     final int[] a = {i};
|     return new Example() {
|       public void reset() {a[0] = 0;}
|       public void next() {
|         java.lang.System.out.println(a[0]++);
|       }
|     };
|   }

Interesting.  When I was using Java, I mostly stayed away from static 
code, and don't think I'd ever noticed that this was possible.  Very 
interesting.  It's too bad about that `final` declaration.  (And thanks 
for the history on that, too.)

 -- Scott

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


Thread

Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-03 16:09 +0100
  Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-04 04:15 +0000
    Re: Comparing some of the ways to create objects Stefan Weiss <krewecherl@gmail.com> - 2016-04-04 15:20 +0200
      Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-05 04:04 +0000
    Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-04 16:48 +0100
      Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-05 04:04 +0000
        Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-07 15:07 +0100
          Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-08 01:10 +0000
            Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-08 14:55 +0100
    Re: Comparing some of the ways to create objects Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-04 22:12 +0200
      Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-05 09:57 +0100
    Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-06 16:41 +0100
      Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-06 23:42 +0000
        Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-07 16:09 +0100
          Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-08 02:05 +0000
            Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-08 15:43 +0100
              Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-09 00:01 +0000
                Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-09 16:46 +0000
                Re: Comparing some of the ways to create objects Scott Sauyet <scott@sauyet.com> - 2016-04-10 16:51 +0000
                Re: Comparing some of the ways to create objects Stanimir Stamenkov <s7an10@netscape.net> - 2016-05-08 17:27 +0300
                Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-10 11:31 +0100
                Re: Comparing some of the ways to create objects John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-10 11:52 +0100

csiph-web