www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Future of D style variadic fuctions

reply "SiegeLord" <none none.com> writes:
For the ignorant: I do NOT mean variadic templates as used by 
std.stdio.

I note that they are not mentioned in TDPL. What is the deal with 
them and their future? I'll be very displeased if I have to 
recode a good bit of Tango that uses them if they are removed... 
None of my attempts at coding a replacement for them using 
variadic templates have matched their efficiency (in terms of 
generated code size) or ease of use (they invariably require a 
shim function).

-SL
May 08 2012
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-05-09 08:10, SiegeLord wrote:
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).

 -SL

I really hope they stay. Template functions cannot be virtual. -- /Jacob Carlborg
May 09 2012
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Wednesday, May 09, 2012 11:38:05 Jacob Carlborg wrote:
 On 2012-05-09 08:10, SiegeLord wrote:
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.
 
 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).


I wouldn't expect something like that to be removed from the language at this point, even if it were determined that they had ultimately been a mistake. And just the fact that a major project such as Tango uses them so heavily would be a major reason to keep them. Walter doesn't like making breaking changes without good reason, and even then he's not quick to do it. Heck, there are plenty of features which are definitively going away (e.g. scope on local variables and delete) but they're _still_ haven't even been deprecated yet.
 I really hope they stay. Template functions cannot be virtual.

That's about the only reason that I can think of for keeping them if we were still in the stage where we were making major language changes. The lack of virtuality for templates can be a real pain at times (as much as it makes sense that it's that way). - Jonathan M Davis
May 09 2012
prev sibling next sibling parent Gor Gyolchanyan <gor.f.gyolchanyan gmail.com> writes:
And template functions cannot get instantiated at run-time. Variadic
functions can mimic run-time instantiated template functions.

On Wed, May 9, 2012 at 1:38 PM, Jacob Carlborg <doob me.com> wrote:
 On 2012-05-09 08:10, SiegeLord wrote:
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).

 -SL

I really hope they stay. Template functions cannot be virtual. -- /Jacob Carlborg

-- Bye, Gor Gyolchanyan.
May 09 2012
prev sibling next sibling parent reply deadalnix <deadalnix gmail.com> writes:
Le 09/05/2012 08:10, SiegeLord a écrit :
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).

 -SL

They are useful to interface with existing C code and variadic template have drawback (they for instance cannot be virtual). I would discourage using such a feature, unless you are a lib writter that really know what he/she is doing, because it is unsafe. But they are too important to go.
May 09 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-05-09 13:15, deadalnix wrote:
 Le 09/05/2012 08:10, SiegeLord a écrit :
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).

 -SL

They are useful to interface with existing C code and variadic template have drawback (they for instance cannot be virtual).

C variadics are note the same as D variadics. D has four kinds of variadics: * Template * D style * Type safe * C style -- /Jacob Carlborg
May 09 2012
next sibling parent deadalnix <deadalnix gmail.com> writes:
Le 09/05/2012 13:57, Jacob Carlborg a écrit :
 On 2012-05-09 13:15, deadalnix wrote:
 Le 09/05/2012 08:10, SiegeLord a écrit :
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).

 -SL

They are useful to interface with existing C code and variadic template have drawback (they for instance cannot be virtual).

C variadics are note the same as D variadics. D has four kinds of variadics: * Template * D style * Type safe * C style

If I restate, we have to support C variadic functions. So, I wouldn't make sense to not provide them in D. Additionnaly, it wouldn't make sense either to not be benefit from the type safety added.
May 09 2012
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2012-05-09 15:10, Lars T. Kyllingstad wrote:
 On Wednesday, 9 May 2012 at 11:57:46 UTC, Jacob Carlborg wrote:

 * Template
 * D style
 * Type safe
 * C style

Five, if you count lazy variadics.

You see, I even forgot one :) But that one could also be considered a specialized type safe variadic function. -- /Jacob Carlborg
May 09 2012
prev sibling next sibling parent "Lars T. Kyllingstad" <public kyllingen.net> writes:
On Wednesday, 9 May 2012 at 11:57:46 UTC, Jacob Carlborg wrote:
 On 2012-05-09 13:15, deadalnix wrote:
 Le 09/05/2012 08:10, SiegeLord a écrit :
 For the ignorant: I do NOT mean variadic templates as used by 
 std.stdio.

 I note that they are not mentioned in TDPL. What is the deal 
 with them
 and their future? I'll be very displeased if I have to recode 
 a good bit
 of Tango that uses them if they are removed... None of my 
 attempts at
 coding a replacement for them using variadic templates have 
 matched
 their efficiency (in terms of generated code size) or ease of 
 use (they
 invariably require a shim function).

 -SL

They are useful to interface with existing C code and variadic template have drawback (they for instance cannot be virtual).

C variadics are note the same as D variadics. D has four kinds of variadics: * Template * D style * Type safe * C style

Five, if you count lazy variadics. -Lars
May 09 2012
prev sibling next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Wed, 09 May 2012 02:10:12 -0400, SiegeLord <none none.com> wrote:

 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them  
 and their future? I'll be very displeased if I have to recode a good bit  
 of Tango that uses them if they are removed... None of my attempts at  
 coding a replacement for them using variadic templates have matched  
 their efficiency (in terms of generated code size) or ease of use (they  
 invariably require a shim function).

Not being mentioned in TDPL does not mean it will not be part of the language. Andrei purposely left out quite a few features and constructs because they weren't finalized or were in flux. That *doesn't* really include variadics, since those have been around for ages. But I wouldn't read too much into TDPL not including something. And I would be wholly against D removing D style variadics. Phobos has opted mostly for compile-time type info over runtime type info, but there are scores of libraries that use runtime type info. I'd be disappointed and shocked if that aspect was removed. -Steve
May 09 2012
prev sibling parent reply mta`chrono <chrono mta-international.net> writes:
Am 09.05.2012 08:10, schrieb SiegeLord:
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.
 
 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).
 
 -SL

I remember that we already had a discussion of that long ago, but why not just replacing them with variadic templates like I did in my tango fork. Basically you only need to change tango.text.convert.Layout heavily. The rest are trivial changes on every stuff that is using tango's formater. But that doesn't have to necessarily say that you're breaking existing code!
May 09 2012
parent deadalnix <deadalnix gmail.com> writes:
Le 09/05/2012 18:11, mta`chrono a écrit :
 Am 09.05.2012 08:10, schrieb SiegeLord:
 For the ignorant: I do NOT mean variadic templates as used by std.stdio.

 I note that they are not mentioned in TDPL. What is the deal with them
 and their future? I'll be very displeased if I have to recode a good bit
 of Tango that uses them if they are removed... None of my attempts at
 coding a replacement for them using variadic templates have matched
 their efficiency (in terms of generated code size) or ease of use (they
 invariably require a shim function).

 -SL

I remember that we already had a discussion of that long ago, but why not just replacing them with variadic templates like I did in my tango fork. Basically you only need to change tango.text.convert.Layout heavily. The rest are trivial changes on every stuff that is using tango's formater. But that doesn't have to necessarily say that you're breaking existing code!

Template don't work when it come to OOP and polymorphism. Or if you want your interface to be an opaque API to a binary blob.
May 09 2012