🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #254

foo() => foo

#254
From: Krste Asanovic
Date: Fri, 03 Aug 1990 01:49
44 lines
1593 bytes
Suggestion: If a function can be called with no arguments, then it
should be possible to call it without using the superfluous empty
parenthesis. E.g.

class A
{ public:
    A(int i = 0) { val = i; };
    int value() { return val; };
  private:
    int val;
};

main()
{
    A a;
    int b;

    b = a.value;
    b = a.value(); // Still legal of course.
}

It would appear that this would be a fairly minor change. It is
illegal to declare a variable and function with the same name in the
same scope, so there should be no ambiguity (or am I missing something
subtle in the parser?). This allows the user to ignore whether a data
member like object is implemented as a data member or as a member
function.  It also saves a lot of ugly parens in code such as:

foo.bar().far().boo()  = foo2.bar3().far4().boo5()

which might be written as

foo.bar.far.boo = foo2.bar3.far4.boo5

Something similar already occurs in constructors, e.g. the definition
of "a" in main above.





    

    
Technical Details
Message-ID: <26717@pasteur.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!helios.ee.lbl.gov!pasteur!ICSI.Berkeley.EDU!krste

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!swrinde!ucsd!helios.ee.lbl.gov!pasteur!ICSI.Berkeley.EDU!krste
From: krste@ICSI.Berkeley.EDU ( Krste Asanovic)
Newsgroups: comp.std.c++
Subject: foo() => foo
Keywords: function call syntax
Message-ID: <26717@pasteur.Berkeley.EDU>
Date: 3 Aug 90 01:49:11 GMT
Sender: news@pasteur.Berkeley.EDU
Reply-To: krste@ICSI.Berkeley.EDU ( Krste Asanovic)
Organization: International Computer Science Institute, Berkeley, CA
Lines: 44
X-Local-Date: 2 Aug 90 18:49:11 PDT