Re: Better RecursiveTask Example

Nathan Reynolds via Concurrency-interest <[email protected]> Wed, 24 Nov 2021 15:28:00 -0700
Newsgroups gmane.comp.java.jsr.166-concurrency
Message-ID <CALMUwcpZAg03F_UYqVHkMbEQL9MzP-nVAGZZyMJo+pHA9h2n9A@mail.gmail.com>
--===============6207210435779918291==
Content-Type: multipart/alternative; boundary="000000000000a7048105d1905fd0"

--000000000000a7048105d1905fd0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

We are looking for clarity.  Too many examples online don't include package
or variable types and it makes it very hard to understand how to adapt the
code to my needs.

On Wed, Nov 24, 2021, 3:09 PM Tim Peierls via Concurrency-interest <
[email protected]> wrote:

> On Wed, Nov 24, 2021 at 4:14 PM Remi Forax via Concurrency-interest
> [email protected]
> <http://mailto:[email protected]> wrote:
>
> We can also use =E2=80=98var=E2=80=99, every declarations are aligned but=
 it is perhaps
> harder to understand
>
> *   protected BigInteger compute() {
> *     if (from =3D=3D to) {               // base case
> *       return (from =3D=3D 0) ? BigInteger.ONE : BigInteger.valueOf(from=
);
> *     }
> *     var mid =3D (from + to) >>> 1;    // split in half
> *     var leftTask =3D new FactorialTask(from, mid).fork();
> *     var rightTask =3D new FactorialTask(mid + 1, to);
> *     var right =3D rightTask.invoke(); // perform half the work locally
> *     var left =3D leftTask.join();
> *     return left.multiply(right);
> *   }
>
> It is *definitely *harder to understand. My brain is wired to look on the
> left for types. Lines that are all lower-case initial before an =3D don=
=E2=80=99t
> look like sources of type information to me.
>
> =E2=80=94tim
>
> _______________________________________________
> Concurrency-interest mailing list
> [email protected]
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>

--000000000000a7048105d1905fd0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">We are looking for clarity.=C2=A0 Too many examples onlin=
e don&#39;t include package or variable types and it makes it very hard to =
understand how to adapt the code to my needs.</div><br><div class=3D"gmail_=
quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Nov 24, 2021, 3:09 PM =
Tim Peierls via Concurrency-interest &lt;<a href=3D"mailto:concurrency-inte=
[email protected]">[email protected]</a>&gt; wrote:<br></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div dir=3D"ltr"></div>=
<div><p style=3D"margin:0px 0px 1.2em!important">On Wed, Nov 24, 2021 at 4:=
14 PM Remi Forax via Concurrency-interest <a href=3D"http://mailto:concurre=
[email protected]" target=3D"_blank" rel=3D"noreferrer">concurrenc=
[email protected]</a> wrote:</p>
<blockquote style=3D"margin:1.2em 0px;border-left:4px solid rgb(221,221,221=
);padding:0px 1em;color:rgb(119,119,119);quotes:none">
<p style=3D"margin:0px 0px 1.2em!important">We can also use =E2=80=98var=E2=
=80=99, every declarations are aligned but it is perhaps harder to understa=
nd</p>
</blockquote>
<pre style=3D"font-size:0.85em;font-family:Consolas,Inconsolata,Courier,mon=
ospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style=3D"fon=
t-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px=
 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234=
,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;wh=
ite-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204=
,204,204);padding:0.5em 0.7em;display:block!important">*   protected BigInt=
eger compute() {
*     if (from =3D=3D to) {               // base case
*       return (from =3D=3D 0) ? BigInteger.ONE : BigInteger.valueOf(from);
*     }
*     var mid =3D (from + to) &gt;&gt;&gt; 1;    // split in half
*     var leftTask =3D new FactorialTask(from, mid).fork();
*     var rightTask =3D new FactorialTask(mid + 1, to);
*     var right =3D rightTask.invoke(); // perform half the work locally
*     var left =3D leftTask.join();
*     return left.multiply(right);
*   }
</code></pre><p style=3D"margin:0px 0px 1.2em!important">It is <b>definitel=
y </b>harder to understand. My brain is wired to look on the left for types=
. Lines that are all lower-case initial before an <code style=3D"font-size:=
0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em=
;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);b=
ackground-color:rgb(248,248,248);border-radius:3px;display:inline">=3D</cod=
e> don=E2=80=99t look like sources of type information to me.</p>
<p style=3D"margin:0px 0px 1.2em!important">=E2=80=94tim</p>
<div title=3D"MDH:PGRpdiBkaXI9Imx0ciIgZ21haWxfb3JpZ2luYWw9IjEiPk9uIFdlZCwgT=
m92IDI0LCAyMDIxIGF0
IDQ6MTQgUE0gUmVtaSBGb3JheCB2aWEgQ29uY3VycmVuY3ktaW50ZXJlc3QgJmx0O2NvbmN1cnJ=
l
bmN5LWludGVyZXN0QGNzLm9zd2Vnby5lZHUmZ3Q7IHdyb3RlOjwvZGl2PjxkaXYgZGlyPSJsdHI=
i
IGdtYWlsX29yaWdpbmFsPSIxIj4mZ3Q7IFdlIGNhbiBhbHNvIHVzZSAndmFyJywgZXZlcnkgZGV=
j
bGFyYXRpb25zIGFyZSBhbGlnbmVkIGJ1dCBpdCBpcyBwZXJoYXBzIGhhcmRlciB0byB1bmRlcnN=
0
YW5kPC9kaXY+PGRpdiBjbGFzcz0iZ21haWxfcXVvdGUiPjxkaXY+Jm5ic3A7PC9kaXY+PGRpdj5=
g
YGA8L2Rpdj4qICZuYnNwOyBwcm90ZWN0ZWQgQmlnSW50ZWdlciBjb21wdXRlKCkgezxicj4qICZ=
u
YnNwOyAmbmJzcDsgaWYgKGZyb20gPT0gdG8pIHsgJm5ic3A7ICZuYnNwOyAmbmJzcDsgJm5ic3A=
7
ICZuYnNwOyAmbmJzcDsgJm5ic3A7IC8vIGJhc2UgY2FzZTxicj4qICZuYnNwOyAmbmJzcDsgJm5=
i
c3A7IHJldHVybiAoZnJvbSA9PSAwKSA/IEJpZ0ludGVnZXIuT05FIDogQmlnSW50ZWdlci52YWx=
1
ZU9mKGZyb20pOzxicj4qICZuYnNwOyAmbmJz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quote"><div><br></div>=
</div></div>
_______________________________________________<br>
Concurrency-interest mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank" rel=
=3D"noreferrer">[email protected]</a><br>
<a href=3D"http://cs.oswego.edu/mailman/listinfo/concurrency-interest" rel=
=3D"noreferrer noreferrer" target=3D"_blank">http://cs.oswego.edu/mailman/l=
istinfo/concurrency-interest</a><br>
</blockquote></div>

--000000000000a7048105d1905fd0--

--===============6207210435779918291==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Concurrency-interest mailing list
[email protected]
http://cs.oswego.edu/mailman/listinfo/concurrency-interest

--===============6207210435779918291==--