Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #562

Re: Proposal: Compilation-unit scoped private member functions

From Francis Glassborow<francis.glassborow@btinternet.com>
Newsgroups comp.std.c++
Subject Re: Proposal: Compilation-unit scoped private member functions
Date 2012-12-14 09:10 -0800
Organization unknown
Message-ID <obidnRd0A4OiYjDNnZ2dnUVZ8m6dnZ2d@bt.com> (permalink)
References <ff2d9902-a232-40f4-9e22-97b2563099f8@googlegroups.com>

Show all headers | View raw


On 21/11/2012 19:29, kfsone@googlemail.com wrote:
>  I'd like to propose a relatively minor language change that would help with code-hygiene in two main senses:
>     . Encourage compartmentalization (break large functions up into named fragments),
>     . Encourage privacy and encapsulation (conceal the compartmentalization from the public API),
>

Obviously I have failed to grasp what you are trying to achieve because
when faced with complicated member function definitions I have always
used something like the following:

in Example.h

class Example {
    void foo();
    // rest of public interface
private
    // private interface including
    int a;
    float f;
    double d;
    type t;
};


in Example,cpp

#include "Example.h"
    namespace {
        inline void helper1(int&  i, type const&  t){
           // whatever
        }
        inline void helper2(float&  f){
            ?? whatever
        }
// etc
    }
    void Example::foo(){
         helper1(i, t);
         helper2(f);
// etc
    }


On most implementations there will not even be a cost for those pass be
reference, the implementation will simply inline everything and use the
original member data directly.

Now what does your proposal offer that the above does not provide (that
is also worth the expenditure of 100+ hours of WG21 human resources)

Francis



-- 
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Proposal: Compilation-unit scoped private member functions kfsone@googlemail.com - 2012-11-21 11:29 -0800
  Re: Proposal: Compilation-unit scoped private member functions Francis Glassborow<francis.glassborow@btinternet.com> - 2012-12-14 09:10 -0800
  Re: Proposal: Compilation-unit scoped private member functions Daniel Krügler<daniel.kruegler@googlemail.com> - 2012-12-14 09:11 -0800
  Re: Proposal: Compilation-unit scoped private member functions Ian Collins<ian-news@this.is.invalid> - 2012-12-14 09:19 -0800
    Re: Proposal: Compilation-unit scoped private member functions christopher.dearlove@googlemail.com - 2012-12-17 08:52 -0800
      Re: Proposal: Compilation-unit scoped private member functions Ian Collins<ian-news@this.is.invalid> - 2012-12-18 16:06 -0600
        Re: Proposal: Compilation-unit scoped private member functions christopher.dearlove@googlemail.com - 2013-02-22 10:48 -0600
          Re: Proposal: Compilation-unit scoped private member functions ootiib@hot.ee - 2013-02-22 16:39 -0600
            Re: Proposal: Compilation-unit scoped private member functions Jason McKesson <jmckesson@googlemail.com> - 2013-02-23 23:22 -0800
              Re: Proposal: Compilation-unit scoped private member functions Balog Pal<pasa@lib.hu> - 2013-02-25 11:01 -0600
          Re: Proposal: Compilation-unit scoped private member functions Ian Collins <ian-news@this.is.invalid> - 2013-02-23 18:21 -0800
            Re: Proposal: Compilation-unit scoped private member functions christopher.dearlove@googlemail.com - 2013-02-25 10:59 -0600
    Re: Proposal: Compilation-unit scoped private member functions Balog Pal<pasa@lib.hu> - 2013-02-25 11:01 -0600
      Re: Proposal: Compilation-unit scoped private member functions Andy Lutomirski <luto@amacapital.net> - 2013-02-28 22:16 -0800

csiph-web