Re: Template return values?

2012-12-10 Thread Jesse Phillips
On Thursday, 6 December 2012 at 00:31:53 UTC, Jonathan M Davis wrote: Pretty much the only kind of situation that I remember running into where I would consider Variant to be a good solution is one where you literally have to return a type from a function where you can't know that type at com

Re: Template return values?

2012-12-05 Thread Era Scarecrow
On Wednesday, 5 December 2012 at 19:32:03 UTC, Jonathan M Davis wrote: Yes, but that inevitably forces you to check the type in order to handle it correctly, which means that implicit conversion just doesn't work. In order for implicit conversion to work, you have to be able to assume that you'

Re: Template return values?

2012-12-05 Thread Jonathan M Davis
On Thursday, December 06, 2012 01:06:33 Dmitry Olshansky wrote: > > To know what on earth you're suposed to do with the variable. If it's a > > type that you can't handle, then yes, you'd probably have to throw an > > exception, but you generally use a Variant because you need to be able to > > ret

Re: Template return values?

2012-12-05 Thread Era Scarecrow
On Wednesday, 5 December 2012 at 21:39:31 UTC, Era Scarecrow wrote: My god did it finally post? Sorry if it repeated a few times... Left it on easily overnight and it still didn't say it posted any of it. :(

Re: Template return values?

2012-12-05 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when I was originally reading about C++ and overloadin

Re: Template return values?

2012-12-05 Thread Dmitry Olshansky
12/5/2012 11:31 PM, Jonathan M Davis пишет: On Wednesday, December 05, 2012 22:07:48 Dmitry Olshansky wrote: 12/5/2012 5:40 AM, Jonathan M Davis пишет: There's nothing natural about Variant. It's attempting to add dynamic typing to a statically typed language. Bleh that smells religious. Ther

Re: Template return values?

2012-12-05 Thread Jonathan M Davis
On Wednesday, December 05, 2012 22:07:48 Dmitry Olshansky wrote: > 12/5/2012 5:40 AM, Jonathan M Davis пишет: > > There's nothing natural about Variant. It's attempting to add dynamic > > typing to a statically typed language. > > Bleh that smells religious. There are cases where one may just go f

Re: Template return values?

2012-12-05 Thread Dmitry Olshansky
12/5/2012 5:40 AM, Jonathan M Davis пишет: On Tuesday, December 04, 2012 23:28:25 Dmitry Olshansky wrote: 12/4/2012 10:40 PM, Jonathan M Davis пишет: On Tuesday, December 04, 2012 21:43:09 Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it mayb

Re: Template return values?

2012-12-05 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when I was originally reading about C++ and overloadin

Re: Template return values?

2012-12-04 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when I was originally reading about C++ and overloadin

Re: Template return values?

2012-12-04 Thread Jonathan M Davis
On Tuesday, December 04, 2012 23:28:25 Dmitry Olshansky wrote: > 12/4/2012 10:40 PM, Jonathan M Davis пишет: > > On Tuesday, December 04, 2012 21:43:09 Dmitry Olshansky wrote: > >> Well TDPL claims multiple alias this is allowed so in some distant > >> future it maybe possible for Varaint to alias

Re: Template return values?

2012-12-04 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when I was originally reading about C++ and overloadin

Re: Template return values?

2012-12-04 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when I was originally reading about C++ and overloadin

Re: Template return values?

2012-12-04 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when I was originally reading about C++ and overloadin

Re: Template return values?

2012-12-04 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 17:43:21 UTC, Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. Maybe I remember back when i was originally reading about C++ and overloadin

Re: Template return values?

2012-12-04 Thread Dmitry Olshansky
12/4/2012 10:40 PM, Jonathan M Davis пишет: On Tuesday, December 04, 2012 21:43:09 Dmitry Olshansky wrote: Well TDPL claims multiple alias this is allowed so in some distant future it maybe possible for Varaint to alias this to all built-in types. That would be pretty hideous IMHO. There's a r

Re: Template return values?

2012-12-04 Thread Jonathan M Davis
On Tuesday, December 04, 2012 21:43:09 Dmitry Olshansky wrote: > Well TDPL claims multiple alias this is allowed so in some distant > future it maybe possible for Varaint to alias this to all built-in types. That would be pretty hideous IMHO. There's a reason that D eschews implicit conversions i

Re: Template return values?

2012-12-04 Thread Jacob Carlborg
On 2012-12-04 13:59, Era Scarecrow wrote: It also doesn't seem like it would be difficult to add, only 'auto' would cause any real errors (as it's not a known type it can return). It has been suggested before, overriding on the return type. I has more problems that one might think first.

Re: Template return values?

2012-12-04 Thread Dmitry Olshansky
12/4/2012 4:08 PM, Jacob Carlborg пишет: On 2012-12-04 08:48, Era Scarecrow wrote: A thought's been going through my head for a while now. I wonder about template return values. Function signatures are usually the inputs and NOT the return type. However for writing a variant type could

Re: Template return values?

2012-12-04 Thread Era Scarecrow
On Tuesday, 4 December 2012 at 12:48:57 UTC, bearophile wrote: Era Scarecrow: So then in theory Variant v; int i = v.getValue; //calls getValue!int() Meant it to be long i, but the idea is the same. I think this is not possible in D. This seems possible: auto i = v.getValue!int; Inde

Re: Template return values?

2012-12-04 Thread bearophile
Era Scarecrow: So then in theory Variant v; int i = v.getValue; //calls getValue!int() I think this is not possible in D. This seems possible: auto i = v.getValue!int; Bye, bearophile

Re: Template return values?

2012-12-04 Thread Jacob Carlborg
On 2012-12-04 08:48, Era Scarecrow wrote: A thought's been going through my head for a while now. I wonder about template return values. Function signatures are usually the inputs and NOT the return type. However for writing a variant type could be so very useful. So unless I've mis

Template return values?

2012-12-03 Thread Era Scarecrow
A thought's been going through my head for a while now. I wonder about template return values. Function signatures are usually the inputs and NOT the return type. However for writing a variant type could be so very useful. So unless I've misunderstood, this doesn't work (but i