www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5368] New: Remove Typesafe Variadic Functions for class objects

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5368

           Summary: Remove Typesafe Variadic Functions for class objects
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2010-12-24 00:47:44 PST ---
I suggest to remove a feature from the D2 language, "Typesafe Variadic
Functions" for class objects:
http://www.digitalmars.com/d/2.0/function.html

This is the example in the docs:


class Foo
{
    int x;
    char[] s;

    this(int x, char[] s)
    {
    this.x = x;
    this.s = s;
    }
}

void test(int x, Foo f ...);

...

Foo g = new Foo(3, "abc");
test(1, g);        // ok, since g is an instance of Foo
test(1, 4, "def");    // ok
test(1, 5);        // error, no matching constructor for Foo


In the last years I have never used this feature, so I think it's not useful
often enough.

Once the feature is missing you have to replace code like this:
test(1, 4, "def");

With:
test(1, new Foo(4, "def"));

So it doesn't seem a significant loss.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 24 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5368


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-23
17:45:58 PST ---
It's definitely a weird feature I've never seen used before. What was the
rationale for adding this? Is it some feature ported from another language?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 23 2013