Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #676 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

Tango Variant implementation issues

Reported by: aarti_pl Assigned to: DRK
Priority: major Milestone: 0.99.4
Component: Core Functionality Version: 0.99.2 Don
Keywords: Cc:

Description

1. It looks that opAssign is not very well suited for containers of this type. The problem is that it disallows to put Variant into Variant (what is sometimes very useful), as operator will not start work at all, but just pointers to/values of containers will be replaced. Because of that it would be probably better to have only free function variant!(T)(T value); which would create new Variant's and drop opAssign operator. It's also possible to have both (opAssign and free function), but it would be probably confusing.

2. There is no isEmpty() function. I think that clear() would be nice also, but maybe not so useful.

3. Automatic conversion of arguments to variadic argument functions into Variant should be possible (Boxer has it).

4. toUtf8 doesn't work

Change History

11/12/07 06:14:11 changed by larsivi

  • owner changed from sean to DRK.

11/12/07 18:21:30 changed by DRK

1. I'm yet to see a compelling argument for this. From my POV, it's basically asking to put a variable inside another variable. There is no type in D, or any language that I'm aware of that lets you do this. If there is a compelling use case for it, the most I would want to do is add some sort of .assignRaw member or somesuch. I think the opAssign behaviour is too useful and obvious to break for a single edge-case.

2. Agreed. v.isA!(void) and v = v.init; are a bit obscure.

3. Agreed. I've just never gotten around to writing it, since I've never needed it.

4. Not my fault. If you go back to the original Variant on Wiki4D (http://www.prowiki.org/wiki4d/wiki.cgi?DanielKeep/Variant) toUtf8 works. The reason it was removed is that Tango doesn't like having too many interdependencies in the code, and toUtf8 would have made tango.core dependent on tango.text.convert. It might be possible to get it functioning again by re-implementing the necessary parts of tango.text.convert directly in Variant, but I'd rather not if I don't have to.

Anyway, I'll put this ticket on the list of things to do; I'll get on it when I've got time. *grumbles about having to type this out twice*

11/13/07 03:51:21 changed by larsivi

  • milestone changed from 0.99.3 to 0.99.4.

12/18/07 21:17:08 changed by DRK

As of revision 3045, I've addressed point 2 above. I will likely get around to 3. eventually, just haven't had time as of yet.

As for the other points you made, I still stand by my assessment of point 1. 4. isn't likely to be addressed unless Variant moves out of the core package, I'm afraid.

12/19/07 04:17:07 changed by larsivi

  • status changed from new to closed.
  • resolution set to fixed.

I am closing this ticket, I don't like having several issues in one if they are not easily solved by the same work.

Issue 3 is now #821. Open a new ticket for 1 if there are true compelling arguments for this feature.

Regarding 4, support for formatting Variant via the formatter will eventually be supported, whereas deep support for toString via the formatter, that is dependency on the formatter inside Variant, will not happen. Other solutions (if they exist) may be considered, in which case a new ticket should be created.