Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Anton Shepelev Newsgroups: comp.lang.javascript Subject: Re: input/output parameters Date: Sat, 20 Mar 2021 15:50:06 +0300 Organization: A noiseless patient Spider Lines: 52 Message-ID: <20210320155006.f1909610fd93de6c3afec7cb@gmail.com> References: <20210313153232.40fa0c8b0adf07d7e807084d@gmail.com> <20210315002732.dbb3221feb6d3a0c065292cf@gmail.com> <604f92ed$0$13963$e4fe514c@newszilla.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Info: reader02.eternal-september.org; posting-host="0b6de666454792515201e0a3034742c6"; logging-data="7403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188k4PswbXu/lSXC+ls+FF3Zt2b+Fq8H8g=" Cancel-Lock: sha1:O/HZCv04HHhA65Mjw+AI6JfiYhY= X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Xref: csiph.com comp.lang.javascript:39718 Silvio: > Give it up. The first mistakes beginners make when > learning a new language is trying to coerce them into the > programming style they used in their previous language. It is not about style but about the whole paradigm, the way one thinks about problems. Consider the programming languages designed by Niklaus Wirth. They are all different, with their own idioms and keywords and statements, yet they all encourage the same disciplied, academic approach and clean programming style. I am thankful to languages that do not force the user to resort to their complicated object- oriented or functional infractructures, letting him express himself in the basic terms of procedural programming. In C#, for example, one can use static classes and methods for modules. That said, I have no trouble switching between C, C#, Pascal, or GNU Troff, or Bash. Naturally, I do not redefine curly braces as `begin' and `end', but use whatever facilities the language provides for procedural programming with more or less success. > Out parameters where a bad idea from the get go in any > language that contained them dating back at least as far > as Algol 60 and dozens of subsequent languages. Why are they a bad idea? I do not remember that such promiment computer scientists as Nickaus Wirth, Donald Knuth, or Edjger Dijkstra criticised them. Nor such promiment programmers as Brian Kernighan or Linus Torvalds. > Obviously they had to be added to the be-all-and-end-all > that has become C++ with the introduction of references > and from there they made their way into C#. Forget about > them and you will not bother looking back. I still fail to see elegant alternatives. Multiple assignments (destructuring) do not entirely replace them. Futhermore, output parameters are logical from the viewpoint of symmetry: if a procedure or function may accept a several input parameters, there no reason it should not several several output parameters too. I see that JavaScript tries to replace them with its various exotic facilities, each of which is more comlicated than than the thing it replaces. -- () ascii ribbon campaign -- against html e-mail /\ http://preview.tinyurl.com/qcy6mjc [archived]