Difference between revisions of "Talk:Objectless Calls"
Line 4: | Line 4: | ||
Non-polymorphic inheritance shouldn't have a performance hit unless it's not being optimized, by definition they're monomorphic calls so they can be static and inlined. | Non-polymorphic inheritance shouldn't have a performance hit unless it's not being optimized, by definition they're monomorphic calls so they can be static and inlined. | ||
+ | |||
+ | |||
+ | --[[User:Clemahieu|Clemahieu]] 14:43, 14 March 2008 (PDT) | ||
+ | <e> | ||
+ | class A_CLIENT | ||
+ | inherit{NONE} | ||
+ | A_VALIDATOR | ||
+ | process (a_value: ?VALUE) | ||
+ | local | ||
+ | l_a: A | ||
+ | do | ||
+ | if is_valid_value (a_value) then | ||
+ | create l_a.make (a_value) | ||
+ | ... | ||
+ | end | ||
+ | end | ||
+ | </e> |
Revision as of 12:43, 14 March 2008
Why couldn't the client needing to validate parameters inherit{NONE} from A_VALIDATOR instead of creating an instance?
Also your validation feature doesn't have a postcondition so it's really an incomplete contract. If your validation feature is supposed to ensure something, it needs to state that, otherwise you're just saying, in order to create this object it needs to satisfy this routine which can be overidden and since there's no postcondition, it could be overridden to mean anything including nothing and that's a bug.
Non-polymorphic inheritance shouldn't have a performance hit unless it's not being optimized, by definition they're monomorphic calls so they can be static and inlined.
--Clemahieu 14:43, 14 March 2008 (PDT)
class A_CLIENT inherit{NONE} A_VALIDATOR process (a_value: ?VALUE) local l_a: A do if is_valid_value (a_value) then create l_a.make (a_value) ... end end