[Tutor] beginning to code

Bill BILL_NOSPAM at whoknows.net
Thu Sep 21 18:35:22 EDT 2017


Stefan Ram wrote:
> Bill <BILL_NOSPAM at whoknows.net> writes:
>> 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)?        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.
>    From the point of view of a C++ programmer,
Oh, we "all look the same", huh?  I know that we've only just met, but I 
will caution that you are coming across as something of a "know-it-all".

Bill




> the above
>    is not obfuscated, but it is readable and simple C++.
>    It is of course not readable for readers who do not know
>    C++. Just as Python's »string[::-1]« appears "obfuscated"
>    to readers who don't know Python.
>
>    It was the answer to the question "How can I express the
>    class I'm in in, when I can't write that classes name
>    literally? So, »S« is »example«.
>
>    It works like this: The type of »&f« is »void ( example::*
>    )()«. So, the function-declaration template »T« infers »C«
>    to be »example«, and the type of »T( &f )« is »example«,
>    which then is transferred to the name »S« using typedef.
>
>    This is obvious for C++ programmers, but it takes a lot
>    of time to become a C++ programmer, maybe more than it
>    takes to become a Python programmer.
>




More information about the Python-list mailing list