"You're being pedantic dude."<div><br></div><div>If I argued only from syntactic consistency, you'd have a point. Frankly, I don't really care about syntactic consistency, if it doesn't get me something. Having to type less gets me something. Having more readable code gets me something. Those are practical considerations, not mere pedantic ones. Dude.</div>
<div><br></div><div>What you have as<br><br> some_func(X, Y) -><br> %% Long bit of code<br> ...;<br> some_func(X, []) -><br> %% More code</div><div><br></div><div>could, as I proposed above, also be written</div>
<div><br></div><div> some_func</div><div> (X,Y) -> %% long bit of code</div><div> ...;</div><div> (X,[]) -> %% More code</div><div> ....</div><div><br></div><div>Why is this less readable to you? You could answer, "Because it's not what I'm used to seeing in Erlang programs," but that begs the question. If people were more used to seeing the latter -- because making Erlang syntactically more self-consistent made it possible -- that argument wouldn't have much force -- except as an argument from pure conservatism.</div>
<div><br></div><div>And this is entirely apart from "long bit of code" being a classic Smell anyway:</div><div><br></div><div> <a href="http://www.soberit.hut.fi/mmantyla/BadCodeSmellsTaxonomy.htm">http://www.soberit.hut.fi/mmantyla/BadCodeSmellsTaxonomy.htm</a></div>
<div><br></div><div>-michael turner<br><br></div><div><br><div class="gmail_quote">On Thu, May 19, 2011 at 12:11 AM, Parnell Springmeyer <span dir="ltr"><<a href="mailto:ixmatus@gmail.com">ixmatus@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<br>
You're being pedantic dude. I'm sure Joe Armstrong and the other<br>
programmers that designed and work on Erlang are acutely aware of DRY,<br>
PoLS, and a whole bunch of others.<br>
<br>
Personally, I think it is a feature to state the function name when<br>
defining another function clause.<br>
<br>
some_func(X, Y) -><br>
%% Long bit of code<br>
...;<br>
some_func(X, []) -><br>
%% More code<br>
....<br>
<br>
Without it, scanning the source could get confusing.<br>
<div><div></div><div class="h5"><br>
Michael Turner <<a href="mailto:michael.eugene.turner@gmail.com">michael.eugene.turner@gmail.com</a>> writes:<br>
<br>
> I can say<br>
><br>
> fun (1)->2;<br>
> (2)->1<br>
> end<br>
><br>
> but, oddly, I can't define a named function in the analogous way, e.g.:<br>
><br>
> factorial<br>
> (1) -> 1;<br>
> (N) -> N*factorial(N-1).<br>
><br>
> gives me a syntax error. I find the latter more readable than<br>
><br>
> factorial(1) -> 1;<br>
> factorial(2) -> N*fact(N-1).<br>
><br>
> It's also less to type and to read, which is consistent with the DRY<br>
> principle ("Don't Repeat Yourself"). And it lends itself to reading a<br>
> function definition as a set of cases. I think for Erlang newbies, it<br>
> should therefore would be preferred: it helps underscore the<br>
> pattern-matching style of Erlang function invocation.<br>
><br>
> It also looks a *little* bit more like the mathematical convention for<br>
> defining these sorts of functions, where you have "f(x) = ", centered<br>
> vertically to the left of a big left "{" that (left-)encloses the list<br>
> of expression/parameter-condition pairs in a two-column format, e.g.,<br>
><br>
> <a href="http://cnx.org/content/m29517/latest/Picture%2047.png" target="_blank">http://cnx.org/content/m29517/latest/Picture%2047.png</a><br>
><br>
> So there's a (weak) argument from the Principle of Least Surprise here<br>
> as well.<br>
><br>
> It seems to me that, if anything, this requires only a *simplification*<br>
> of the Erlang parser. That leaves only one obvious objection: would any<br>
> existing code break if Erlang syntax were altered to allow this?<br>
><br>
> -michael turner<br>
><br>
</div></div><div class="im">> _______________________________________________<br>
> erlang-questions mailing list<br>
> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
</div>- --<br>
Parnell "ixmatus" Springmeyer (<a href="http://ixmat.us" target="_blank">http://ixmat.us</a>)<br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)<br>
Comment: GPGTools - <a href="http://gpgtools.org" target="_blank">http://gpgtools.org</a><br>
<br>
iQEcBAEBAgAGBQJN0+GfAAoJEPvtlbpI1POLEMkH/3TKrH5uCapUy+jM2V7+JP43<br>
Fn8EEJIgkuGHd+t1Jp2BI190Yyl+hO1hlarQJzDulGWBdYMtsxIGJ32Za9rJrSyo<br>
C+nzfDpC5cKrLXXlk4vFq+GphnKOoOffQ7FCqQvElL89GBXxt7cvPCjk6X04BuYI<br>
MhQYidxOozerdvNkH1iw9uC61zVhz0ahPqwuMbyzCg71BjLYo8NR+qYpqtiTMHjx<br>
nXar6vcjzsrEQzi5Ul5hWjrgzQQgecFOeeZ5bQjTzhKfHMpUk1beI5rQuYxpuvVd<br>
8kA1YiOU5mfQqoqA+ZKpoG598Isp1vnTc+DQznJC9GbE4mgUWNO5n4J51U2OR5U=<br>
=ypYB<br>
-----END PGP SIGNATURE-----<br>
</blockquote></div><br></div>