Hallo Michael, Du schriebst am Wed, 13 Nov 2013 13:01:42 +0100:
> > The "with" construction is well optimized by complilers. > A decent compiler can do the same optimization even without being hinted > to do so by the programmer's using "with" Yes, with enough implementation effort on the side of the compiler, it can. > > Also without"with" we'll have C-ish nightmare with long chained OOP > > idents. > You can use intermediate variables instead, making (IMHO) the code much > less ambiguous and not much more blurred. A decent compiler can do the same optimization even without being hinted to do so by the programmer's using intermediate variables. Indeed, a strongly optimizing compiler might insert intermediate variables in many places where the programmer didn't think of doing so, and can remove such when the programmer meant them to convey some important information. BTW, intermediate "variables" (I suppose you're thinking of _pointer_ variables here) are very similar to the Oberon-style "with" Martin suggested, they're implicitly declared such variables. And that's why I don't really like them - instead of "opening" the direct access to the fields of a record, it requires you to use an alias name, a nickname for the real variable. Indeed, their handling is very similar to the usage of nicknames for people in some restricted group - if you leave the group, you better not use the nickname, as no one recognizes it outside, it might even be detrimental or at least cause confusion. The same appiles to these intermediate variables, either declared (and assigned) explicitely or by the Oberon-style "with" construct. > BTW.: > I vote for the possibility to define local variables anywhere and not > just before the first begin of a function. That's a completely different thing with an ability to cause confusion. In addition, it simply doesn't fit any Pascal style syntax, not even the older Algol style. Algol _did_ provide block local variables within enclosing blocks, though - it just didn't allow them to be defined "anywhere". Algol, like Pascal, uses separation of declarations and statements, and it did so also for theses variable declarations. I'm not sure any more, and I cannot refer to any documentation right now, but I think the syntax looked somewhat like the normal procedure syntax, just without a header. I.e.: VAR { global declarations } ... { declarations } BEGIN { outermost block } ... { statements } VAR { block local declarations } ... { declarations } BEGIN { interior block } ... { statements } END; ... { statements } END; where the block local declarations are only valid within the interior block, while the global declarations (and any declarations from blocks fully enclosing the interior one) are visible also as long as they're not overridden by more local ones, as usual. (And, as an additional bonus, Algol even allowed to use block external variables in the declaration of block local ones, even for array boundaries and such things.) BTW, there are additional issues with local variables that make them sometimes rather intransparent in C: if the languages provides for preinitialization of variables, how are the initial values handled if a local block gets executed repeatedly? C requires the compiler to generate code to implicitely reinitialize them every time, as long as they're real _local_ variables and not declared "static", what makes them global and initialized only once on program startup. Delphi only initializes them once and makes initialized variables always "C static", i.e. global, although just locally visible. There are other possibilities, but all except the "globalizing" approach need hidden code generation by the compiler. This might be considered unwanted. -- -- (Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem) ----------------------------------------------------------- Mit freundlichen Grüßen, S. Schicktanz ----------------------------------------------------------- ------------------------------------------------------------------------------ DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access Free app hosting. Or install the open source package on any LAMP server. Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native! http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk _______________________________________________ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk