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


Groups > comp.lang.javascript > #30706

Re: Impact of implicit arrays...

From "Chris M. Thomasson" <invalid@invalid.invalid>
Newsgroups comp.lang.javascript
Subject Re: Impact of implicit arrays...
Date 2016-06-21 21:08 -0700
Organization n/a
Message-ID <nkd300$iml$1@dont-email.me> (permalink)
References (1 earlier) <4a1c28ea-447b-4e9b-9c75-68ef85c379e7@googlegroups.com> <njq6qn$qc3$1@gioia.aioe.org> <a1db3c29-049f-44a0-ae2d-e6c38776ddd7@googlegroups.com> <nkccds$mm6$1@dont-email.me> <99986aa5-dd0c-45a1-a294-90d9c5cada54@googlegroups.com>

Show all headers | View raw


On 6/21/2016 5:35 PM, Michael Haufe (TNO) wrote:
> On Tuesday, June 21, 2016 at 4:43:31 PM UTC-5, Chris M. Thomasson wrote:
>
>> So nice! I have not used ES6 and the (class x extends y) technique. I am
>> wondering about browser support for this. How good is it?
>
> <https://kangax.github.io/compat-table/es6/>
>
> In other words, use TypeScript of Babel and integrate it into your IDE, such as VS Code <https://code.visualstudio.com/>.

I notice that Chrome gives me a "Reference Error: this is not defined" 
such that (alert("hello 1");) never gets called in your constructor:
______________________________
constructor(re, im) {
         alert("hello 0");
         this.re = re;
         alert("hello 1");
         this.im = im;
     }
______________________________

I must be creating (ComplexRect) objects in a totally screwed up way:
______________________________
{
    var c = new ComplexRect(-.75, .09);
    alert(c.re + ", " + c.im);
}
______________________________

How do I create instances of (ComplexRect)?

>> Humm... FWIW, for some reason I also really like the simple array based
>> method I am using now.
>
> Which keeps the components implicit, and also makes it a bit harder if you plan to mix/match polar/cartesian coordinates

I need to think here.


>
>> Yours is easier to read, but for me using foo[0] for x, foo[1] for y,
>> ect looks more matrix like wrt indexing into an array; its not all that
>> bad to my eyes.
>
> and yet it isn't a matrix and you don't get the benefit of the operations. it also hides what I mentioned earlier.
>
>> Also, it makes iterating over the elements really intuitive.
>
> There are only two components, why would you iterate?

Because I like to add on extra components for fun/experimental purposes. ;^)

Also, take a look at my (ct_complex_roots) function:
_________________________________________
function ct_complex_roots(c, p)
{
    var l = ct_complex_abs(c);
    var s = Math.pow(l, 1.0 / p);
    var a = Math.atan2(c[1], c[0]) / p;

    var n = Math.ceil(Math.abs(p));
    var as = (Math.PI * 2) / p;
    var roots = [];

    for (var i = 0; i < n; ++i)
    {
        roots.push([Math.cos(a + as * i) * s,
                    Math.sin(a + as * i) * s]);
    }

    return roots;
}
_________________________________________


The return value from this can contain more than two objects, so, IMVHO, 
the ease of iterating the return value (roots) is very nice wrt Arrays.

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


Thread

Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-11 10:52 -0700
  Re: Impact of implicit arrays... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-12 12:16 +0200
    Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-13 12:23 -0700
  Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-13 22:00 -0700
    Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-14 17:17 -0700
      Re: Impact of implicit arrays... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-15 06:55 +0200
      Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.invalid> - 2016-06-14 22:19 -0700
      Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-18 12:47 -0700
        Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 14:43 -0700
          Re: Impact of implicit arrays... "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-22 00:10 +0200
            Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 15:28 -0700
              Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 15:31 -0700
                Re: Impact of implicit arrays... "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-22 11:55 +0200
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 12:23 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:14 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:16 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 18:14 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 18:46 -0700
          Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-21 17:35 -0700
            Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 21:08 -0700
              Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-21 23:09 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:38 -0700
                Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-24 07:16 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-25 18:03 -0700
                Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 18:24 -0700
                Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-07-01 13:52 -0700

csiph-web