> Why would the programmer become confused? In C++ (a mainstream OO > language), if a Dog constructor was defined that took a string as an > argument, the string would be auto-converted to a Dog. Yes, C++ implicitly treats single argument constructors as conversion constructors. They convert the data type of the argument into the expected class. What if you don't want your constructor to act like a conversion operator? C++ requires you to use the 'explicit' keyword. I love the power of C++, but merely tolerate its syntax. I'd like to see Perl provide a better conversions syntax. Perl might be able to deliver conversion operators without constraining its constructor syntax. Perhaps we could steal an idea from C#. C# expects you to define conversion operators instead of implicitly using single-argument constructors for that purpose. In Perl that might be: 1. Reserve 'CONVERT' for conversion constructors? 2. Add a ': conversion' declarator for functions used as conversion operators?
- Re: RFC 171 (v1) my Dog $spot should call a const... Nathan Wiger
- Re: RFC 171 (v1) my Dog $spot should call a constructo... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot should call a const... Nathan Wiger
- Re: RFC 171 (v1) my Dog $spot should call a c... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot should call... Michael Fowler
- Re: RFC 171 (v1) my Dog $spot should ... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot sh... Michael Fowler
- Re: RFC 171 (v1) my Dog $spo... Michael Fowler
- Re: RFC 171 (v1) my Dog $spot should ... Damian Conway
- Re: RFC 171 (v1) my Dog $spot sh... Piers Cawley
- Re: RFC 171 (v1) my Dog $spot should call a constructo... Evan Howarth
- Re: RFC 171 (v1) my Dog $spot should call a constructo... Michael G Schwern
- Re: RFC 171 (v1) my Dog $spot should call a const... James Mastros
- Re: RFC 171 (v1) my Dog $spot should call a c... Jonathan Scott Duff
- Re: RFC 171 (v1) my Dog $spot should call... Tom Christiansen
- Re: RFC 171 (v1) my Dog $spot should ... Buddha Buck
- Re: RFC 171 (v1) my Dog $spot sh... Tom Christiansen
- Re: RFC 171 (v1) my Dog $spot sh... Bart Lateur
- Re: RFC 171 (v1) my Dog $spot should ... Jonathan Scott Duff