www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1598] New: New std.variant is missing functionality from Box

reply d-bugmail puremagic.com writes:
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.




As I see there is not such a possibility in new Variant. 

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






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.


-- 
Oct 19 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1598






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.
*/


-- 
Oct 19 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
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: -------
Oct 11 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1598


Andrei Alexandrescu <andrei metalanguage.com> changed:

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



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: -------
Sep 25 2010