This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Extend existing support for evaluating expressions using overloaded operators

>>>>> "Siva" == Siva Chandra <> writes:

Siva> If we want to extend the operator overloading support into Python,
Siva> then we will have to have code to decide whether to call value_binop
Siva> or value_x_binop in the py-value.c. Another client of these two
Siva> functions is evaluate_subexp_standard, which also has code to decide
Siva> whether to call value_binop or value_x_binop. Though I did not mention
Siva> in my post, my intention is avoid such repetitive code and get all
Siva> clients to depend only on value_binop and treat value_x_binop as
Siva> 'internal'.

I think you should start with this cleanup, then.
After the current patch it seems to me that the code would be inconsistent.

I think this idea is ok in the abstract but you have to be sure to audit
all the existing uses to make sure it does the right thing.  (I don't
anticipate a problem here, but still...)

Siva> I would like to follow this patch with another patch to do
Siva> this change. Note that, only evaluate_subexp_standard calls
Siva> value_x_binop currently. Hence, replacing these calls with value_binop
Siva> should not be much work (though I have not yet come up with a way to
Siva> deal with the 'noside' argument of value_x_binop).

Letting that leak out of eval.c seems like a flaw.

Tom> It would be nice if the test suite tested this case as well.

Siva> I agree, I will add more tests after we finalize this patch.

Siva> + Â Â Â Â{
Siva> + Â Â Â Â Â/* Retrieve the list of methods with the name NAME. Â*/
Siva> + Â Â Â Â Âfns_ptr = value_find_oload_method_list (&temp, name,
Siva> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0, &num_fns,
Siva> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â&basetype, &boffset);
Siva> + Â Â Â Â}
Siva> + Â Â Âif (except.reason < 0)
Siva> + Â Â Â Âfns_ptr = NULL;

Tom> I'll have to go read this in more depth; but I wonder why it is ok to
Tom> ignore exceptions here.

Siva> An exception is thrown if we are trying to lookup methods of a
Siva> non-struct and non-union type. One can ask that, in such cases, why
Siva> call value_find_oload_method_list at all. My argument is, if
Siva> value_find_oload_method_list is doing the check, why should we repeat
Siva> before calling it.

Throwing and catching an exception is much more expensive, and less
clear, than just checking the type.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]