[C++-sig] Re: Allocating objects on the heap by default.

Nicodemus nicodemus at globalite.com.br
Wed Jul 9 18:12:58 CEST 2003


David Abrahams wrote:

>Nicodemus <nicodemus at globalite.com.br> writes:
>
>  
>
>>David Abrahams wrote:
>>
>>    
>>
>>>Pyste is about providing
>>>an even terser syntax for accomplishing the same things, and
>>>'std::auto_ptr<A>' is not only longer but it repeats information.
>>>Also, how will that interface work when you have a class with virtual
>>>functions that you want to be held by auto_ptr?
>>> 
>>>      
>>>
>>I think we can provide functions for the most common smart pointers to
>>be registered directly:
>>
>>hold_with_auto_ptr(A)   # or perhaps: auto_ptr_holder(A)?
>>hold_with_smart_ptr(A)
>>
>>And a more general purpose function for any other smart pointer:
>>
>>hold(A, 'my_smart_ptr<A>')
>>
>>It does duplicate information, but very little in my opinion.
>>    
>>
>
>I think having two such syntaxes is unneccessary; new smart pointer
>varieties are sufficiently rare that the 2nd syntax isn't justified,
>and they're *used* sufficiently often that writing:
>
>  def my_smart_ptr(name):
>      return 'my_smart_ptr<%s>' % name
>
>is justified by the rest of the code that gets written... And
>furthermore, as I keep asking:
>
>  ** What about classes with virtual functions?? **
>
>Do you want to force the user to be knowledgeable about the name of
>the Pyste-generated callback class (they would have to write
>'my_smart_ptr<A_callback>' or whatever it is)?  Do you want to ask
>them to change their Pyste wrapping code just because they add a
>virtual function to their C++ code?
>

Sorry, I missed this point of yours.

You are right, a more dynamic approach is needed. Even thought the 
callable solution is a little verbose, its use will be less frequent, 
and it is worth the flexibility.

Regards,
Nicodemus.






More information about the Cplusplus-sig mailing list