Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.arch Subject: Re: Intel MPX Date: Thu, 17 Dec 2015 23:02:03 +0200 Organization: Tidorum Ltd Lines: 63 Message-ID: References: <3bf7bfbf-ea95-440b-886c-a54edcd78be3@googlegroups.com> <1821eff2-a122-4458-9a87-cf9db7db672d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net jjhQjqc0H+L+vvqJDWkMBAD8I+OlPeTY3cxJ6McrWPB/5KqKc/ Cancel-Lock: sha1:b5bNNX+fXvWEddTXaee987hh5m4= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <1821eff2-a122-4458-9a87-cf9db7db672d@googlegroups.com> Xref: csiph.com comp.arch:31964 On 15-12-17 13:33 , already5chosen@yahoo.com wrote: > On Thursday, December 17, 2015 at 1:11:04 PM UTC+2, Walter Banks > wrote: >> On 15/12/2015 12:57 PM, Megol wrote: >>> On Tuesday, December 15, 2015 at 6:51:07 PM UTC+1, >>> timca...@aol.com wrote: >>>> In the 80s we had Pascal (with real enums, stricter type >>>> checking, and bounds checks built-in to the language) and >>>> protected mode segments (yes, I know, everybody hates them). >>>> In another 20 years we might get C and flat mode addressing to >>>> work almost as well. :) >>> >>> A Pascal dialect with some features from C would be very nice. >>> >> Pascal style local functions in C (I know some C compilers have it >> as an extension) >> >> C has local variables right but Pascal's local functions and the >> way they scope variables is missed when I write application code in >> C. >> >> w.. > > I most definitely do not want a visibility of local variables of > outer function in the inner function (Is what people call closures > ?). That's the feature of Pascal (inherited by Ada) that in my > experience is widely misused and very harmful for code readability. That visibility is easy to control, at least in Ada: if you don't want your local subprogram Bar to have visibility over its containing subprogram's local variable X, write the body of Bar first, and declare X after. > Nested function without such visibility appear harmless and may be > event a little useful. But it seems to me that the main reason for having nested subprograms is indeed to let those subprograms use the containing subprogram's parameters and/or local variables, without having to pass them (again) as parameters. From an object-oriented point of view, the local variables represent the state of an (anonymous) "singleton object" (in the context of a given call), and the nested subprograms are operations on this "singleton object", and therefore do not need to have this object as an explicit parameter. IMO one level of nesting does not harm readability much, but deeper levels of nesting would be harmful. Personally I don't remember ever using even two levels of subprogram nesting, the most I've used is package containing subprograms containing subprograms. Note that if the Ada subprogram Foo contains the nested subprogram Bar, then Bar can refer to a (visible) parameter or local X, of Foo, with the qualified notation "Foo.X", as well as directly with "X". Systematically using Foo.X instead of X could be made a coding rule. In my day job (writing Ada programs) subprogram nesting is forbidden because it is difficult to unit-test the inner subprograms. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .