[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tutor] beginning to code

Stefan Ram wrote:
> bartc <bc at freeuk.com> writes:
>> On 20/09/2017 02:31, Bill wrote:
>>> it's implementation, I would say that C++ has it all over Python from
>>> the point of view of "intuitiveness".  It's much easier to tell what's
>>> going on, at a glance, in a C++ program.
>> You're being serious, aren't you?
>    For one example, this is a part of a C++ program:
> template< typename C >C T( void ( C::* )() );
>    . It defines a template T, that can be used in a
>    class as follows:
> struct example { void f(); typedef decltype( T( &f )) S; };
>    . The type ?S? now has a certain property, that can
>    be useful sometimes. What is this property (asking Bill)?
I'll reveal that I'm not Bjarne Stroustrup.  decltype was introduced in 
C++11, which I haven't explored, and I have never written any code that 
resembles your template.  But it appears that an object of type S may 
behave like a function, which in this case would invoke Example.f().  As 
has already been pointed out, one can write "obfuscating code" in any 
language, with little effort.  I strive to write code which is easily 
understandable--and I document it. I don't wish to debate whether I 
could make more of a mess in Python, or not.