Any should have map for readability
Carl Emmoth <[email protected]> Fri, 5 Aug 2016 02:11:26 -0700 (PDT)
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_105_557449163.1470388286134
Content-Type: multipart/alternative;
boundary="----=_Part_106_1819895676.1470388286135"
------=_Part_106_1819895676.1470388286135
Content-Type: text/plain; charset=UTF-8
Warning: Amateur suggestion!
Example
So there's a lot of code examples in this form:
val server = Http.serve(":8080", service)Await.ready(server)
1. Instancing
2. Calling method with instance
It might look concrete but the instancing looks unnecessary.
Suggestion
Since we usually read from left to right, we would also like to read the
code in chronological order like when using map
Http.serve(":8080", service) map Await.ready
But since Any doesn't have map, a suggested syntax would be
Http.serve(":8080", service) (Await.ready)
Similartiy with Collection
This is similar to collections which have map. Here's examples with map
1 to 3 map println
1 to 3 map (_ + 10) map println
Any without map could be like this then
10 (println)
10 (_ + 10) (println)
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
------=_Part_106_1819895676.1470388286135
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Warning: Amateur suggestion!<div><font size=3D"4">Example<=
/font></div><div>So there's a lot of code examples in this form:</div><=
div><pre style=3D"overflow-x: auto; overflow-y: hidden; font-family: Consol=
as, Menlo, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono&qu=
ot;, monospace; font-size: 0.9em; padding: 10px; line-height: 1.3em; border=
-radius: 5px; border: 1px solid rgb(238, 238, 238); color: rgb(62, 67, 73);=
background: rgb(253, 253, 253);"><span class=3D"k" style=3D"color: rgb(0, =
68, 97); font-weight: bold;">val</span> <span class=3D"n" style=3D"color: r=
gb(0, 0, 0);">server</span> <span class=3D"k" style=3D"color: rgb(0, 68, 97=
); font-weight: bold;">=3D</span> <span class=3D"nc" style=3D"color: rgb(0,=
0, 0);">Http</span><span class=3D"o" style=3D"color: rgb(88, 40, 0);">.</s=
pan><span class=3D"n" style=3D"color: rgb(0, 0, 0);">serve</span><span clas=
s=3D"o" style=3D"color: rgb(88, 40, 0);">(</span><span class=3D"s" style=3D=
"color: rgb(78, 154, 6);">":8080"</span><span class=3D"o" style=
=3D"color: rgb(88, 40, 0);">,</span> <span class=3D"n" style=3D"color: rgb(=
0, 0, 0);">service</span><span class=3D"o" style=3D"color: rgb(88, 40, 0);"=
>)</span>
<span class=3D"nc" style=3D"color: rgb(0, 0, 0);">Await</span><span class=
=3D"o" style=3D"color: rgb(88, 40, 0);">.</span><span class=3D"n" style=3D"=
color: rgb(0, 0, 0);">ready</span><span class=3D"o" style=3D"color: rgb(88,=
40, 0);">(</span><span class=3D"n" style=3D"color: rgb(0, 0, 0);">server</=
span><span class=3D"o" style=3D"color: rgb(88, 40, 0);">)</span></pre></div=
><div><ol><li><span style=3D"line-height: normal;">Instancing=C2=A0</span><=
/li><li><span style=3D"line-height: normal;">Calling method with instance</=
span></li></ol><div>It might look concrete but the instancing looks unneces=
sary.</div></div><div><font size=3D"4">Suggestion</font></div><div>Since we=
usually read from left to right, we would also like to read the code in ch=
ronological order like when using map</div><div><pre style=3D"padding: 10px=
; border: 1px solid rgb(238, 238, 238); overflow-x: auto; overflow-y: hidde=
n; font-family: Consolas, Menlo, "Deja Vu Sans Mono", "Bitst=
ream Vera Sans Mono", monospace; font-size: 0.9em; line-height: 1.3em;=
border-radius: 5px; color: rgb(62, 67, 73); background: rgb(253, 253, 253)=
;"><span class=3D"nc" style=3D"color: rgb(0, 0, 0);">Http</span><span class=
=3D"o" style=3D"color: rgb(88, 40, 0);">.</span><span class=3D"n" style=3D"=
color: rgb(0, 0, 0);">serve</span><span class=3D"o" style=3D"color: rgb(88,=
40, 0);">(</span><span class=3D"s" style=3D"color: rgb(78, 154, 6);">"=
;:8080"</span><span class=3D"o" style=3D"color: rgb(88, 40, 0);">,</sp=
an> <span class=3D"n" style=3D"color: rgb(0, 0, 0);">service</span><span cl=
ass=3D"o" style=3D"color: rgb(88, 40, 0);">) map Await.ready</span></pre></=
div><div><br></div><div>But since Any doesn't have map, a suggested syn=
tax would be</div><div><pre style=3D"padding: 10px; border: 1px solid rgb(2=
38, 238, 238); overflow-x: auto; overflow-y: hidden; font-family: Consolas,=
Menlo, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono"=
, monospace; font-size: 0.9em; line-height: 1.3em; border-radius: 5px; colo=
r: rgb(62, 67, 73); background: rgb(253, 253, 253);"><span class=3D"nc" sty=
le=3D"color: rgb(0, 0, 0);">Http</span><span class=3D"o" style=3D"color: rg=
b(88, 40, 0);">.</span><span class=3D"n" style=3D"color: rgb(0, 0, 0);">ser=
ve</span><span class=3D"o" style=3D"color: rgb(88, 40, 0);">(</span><span c=
lass=3D"s" style=3D"color: rgb(78, 154, 6);">":8080"</span><span =
class=3D"o" style=3D"color: rgb(88, 40, 0);">,</span> <span class=3D"n" sty=
le=3D"color: rgb(0, 0, 0);">service</span><span class=3D"o" style=3D"color:=
rgb(88, 40, 0);">) (Await.ready)</span></pre></div><div><font size=3D"4">S=
imilartiy with Collection</font></div><div>This is similar to collections w=
hich have map. Here's examples with map</div><div><pre style=3D"padding=
: 10px; border: 1px solid rgb(238, 238, 238); overflow-x: auto; overflow-y:=
hidden; font-family: Consolas, Menlo, "Deja Vu Sans Mono", "=
;Bitstream Vera Sans Mono", monospace; font-size: 0.9em; line-height: =
1.3em; border-radius: 5px; background: rgb(253, 253, 253);"><font color=3D"=
#000000">1 to 3 map println</font></pre><pre style=3D"padding: 10px; border=
: 1px solid rgb(238, 238, 238); overflow-x: auto; overflow-y: hidden; borde=
r-radius: 5px; background: rgb(253, 253, 253);"><font color=3D"#000000"><fo=
nt face=3D"Consolas, Menlo, Deja Vu Sans Mono, Bitstream Vera Sans Mono, mo=
nospace"><span style=3D"font-size: 11.7px; line-height: 15.21px;">1 to 3 ma=
p (_ + 10) map println</span><span style=3D"font-size: 0.9em; line-height: =
1.3em;"><br></span></font></font></pre></div><div><br></div><div>Any withou=
t map could be like this then</div><div><pre style=3D"padding: 10px; border=
: 1px solid rgb(238, 238, 238); overflow-x: auto; overflow-y: hidden; font-=
family: Consolas, Menlo, "Deja Vu Sans Mono", "Bitstream Ver=
a Sans Mono", monospace; font-size: 0.9em; line-height: 1.3em; border-=
radius: 5px; background: rgb(253, 253, 253);"><font color=3D"#000000">10 (p=
rintln)</font></pre><pre style=3D"padding: 10px; border: 1px solid rgb(238,=
238, 238); overflow-x: auto; overflow-y: hidden; font-family: Consolas, Me=
nlo, "Deja Vu Sans Mono", "Bitstream Vera Sans Mono", m=
onospace; font-size: 0.9em; line-height: 1.3em; border-radius: 5px; backgro=
und: rgb(253, 253, 253);"><font color=3D"#000000">10 (_ + 10) (println)</fo=
nt></pre></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;scala-language" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">scal=
[email protected]</a>.<br />
For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
s://groups.google.com/d/optout</a>.<br />
------=_Part_106_1819895676.1470388286135--
------=_Part_105_557449163.1470388286134--