Thread overview
[Issue 1598] New: New std.variant is missing functionality from Box
Oct 19, 2007
d-bugmail
Oct 19, 2007
d-bugmail
October 19, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1598

           Summary: New std.variant is missing functionality from Box
           Product: D
           Version: 1.022
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: aarti@interia.pl


1. Converting variadic arguments to function:
Below was possible to achieve with Box.

# void func(...) {
#   Box[] barr = boxArray(_arguments, _argptr);
# }
As I see there is not such a possibility in new Variant.

2. Possibility to assign variant type into variant. Example:

# Variant a, b;
# a = 5;
# b = a;
# writefln(b.type);

std.boxer has functionality to store 'Variable of type Box inside other variable of type Box'. Currently probably it is not possible or at least it is not enough documented how to achieve this.


-- 

October 19, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1598





------- Comment #1 from andrei@metalanguage.com  2007-10-19 17:58 -------
This is by design.  The approach based on _arguments and _argptr loses static type information. Variant needs that information in order to store a type-dependent pointer to function. The approach confers Variant full generality, unlike Box, which has to rely on exhaustive enumeration of a closed set of types.

The feature can be added to Algebraic if needed, which in fact is very similar in functionality with Boxer.

I am adding the following to Variant's documentation.

/*
 * Code that needs functionality similar to the $(D_PARAM boxArray)
 * function in the $(D_PARAM std.boxer) module can achieve it like this:
 *
 * ----
 * // old
 * Box[] fun(...)
 * {
 *     ...
 *     return boxArray(_arguments, _argptr);
 * }
 * // new
 * Variant[] fun(T...)(T args)
 * {
 *     ...
 *     return variantArray(args);
 * }
 * ----
 *
 * This is by design. During construction the $(D_PARAM Variant) needs
 * static type information about the type being held, so as to store a
 * pointer to function for fast retrieval.
*/


-- 

October 11, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1598


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 25, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1598


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |WONTFIX


--- Comment #2 from Andrei Alexandrescu <andrei@metalanguage.com> 2010-09-25 15:42:44 PDT ---
As described in my previous comment.

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