D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5368 - Remove Typesafe Variadic Functions for class objects
Summary: Remove Typesafe Variadic Functions for class objects
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
 
Reported: 2010-12-24 00:47 UTC by bearophile_hugs
Modified: 2024-12-13 17:54 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-12-24 00:47:44 UTC
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.
Comment 1 Andrej Mitrovic 2013-01-23 17:45:58 UTC
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?
Comment 2 dlangBugzillaToGithub 2024-12-13 17:54:36 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18324

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB