October 01, 2012
On Monday, 1 October 2012 at 04:18:52 UTC, Walter Bright wrote:
> Also, consider that in C++ you can throw any type, such as an int. There is no credible way to make this work reasonably in D, as exceptions are all derived from Exception.

You could just detect C++ exceptions in the SEH handler and wrap them in a "ForeignLanguageException" or "CppException" class with a "Variant"-type member.

Not saying that this is necessarily an essential feature, though.

David
October 06, 2012
On 9/30/2012 9:35 PM, Andrej Mitrovic wrote:
> On 10/1/12, Walter Bright <newshound1@digitalmars.com> wrote:
>> Also, consider that in C++ you can throw any type, such as an int. There
>> is no credible way to make this work reasonably in D, as exceptions are
>> all derived from Exception.
>
> Is that a bug or a feature? :)


It's a feature, and I'm not joking.

What is the compelling use case for throwing an int? How could that possibly fit into some encapsulation model? What if library A throws an int, and library B does? Now you catch an int - which did it come from? You've got no clue. It's indistinguishable from garbage.

October 06, 2012
On Sat, 06 Oct 2012 11:38:43 -0700
Walter Bright <newshound2@digitalmars.com> wrote:

> On 9/30/2012 9:35 PM, Andrej Mitrovic wrote:
> > On 10/1/12, Walter Bright <newshound1@digitalmars.com> wrote:
> >> Also, consider that in C++ you can throw any type, such as an int. There is no credible way to make this work reasonably in D, as exceptions are all derived from Exception.
> >
> > Is that a bug or a feature? :)
> 
> 
> It's a feature, and I'm not joking.
> 
> What is the compelling use case for throwing an int? How could that possibly fit into some encapsulation model? What if library A throws an int, and library B does? Now you catch an int - which did it come from? You've got no clue. It's indistinguishable from garbage.
> 

And it's not just int's either. Having to deal with code possibly, or actually, throwing any type that isn't a proper Exception type is a pain in the ass.

October 09, 2012
On 06/10/12 20:38, Walter Bright wrote:
> On 9/30/2012 9:35 PM, Andrej Mitrovic wrote:
>> On 10/1/12, Walter Bright <newshound1@digitalmars.com> wrote:
>>> Also, consider that in C++ you can throw any type, such as an int. There
>>> is no credible way to make this work reasonably in D, as exceptions are
>>> all derived from Exception.
>>
>> Is that a bug or a feature? :)
>
>
> It's a feature, and I'm not joking.
>
> What is the compelling use case for throwing an int? How could that
> possibly fit into some encapsulation model? What if library A throws an
> int, and library B does? Now you catch an int - which did it come from?
> You've got no clue. It's indistinguishable from garbage.
>

Just imagine how much fun could be had, if D let you throw sqrt(17.0) + 37.919i.



1 2 3 4 5
Next ›   Last »