Lies in education [was Re: The "loop and a half"]

bartc bc at freeuk.com
Wed Oct 11 15:16:26 EDT 2017


On 11/10/2017 17:16, Jonathan Cast wrote:
> On Wed, 2017-10-11 at 15:14 +0100, bartc wrote:
>> On 11/10/2017 14:16, Marko Rauhamaa wrote:
>>> Python and C don't try to protect you. In return, you get syntactic
>>> convenience that probably enhances the quality of your programs.
>>
>> Python, maybe. C syntax isn't as painful as C++ but I still have a lot
>> of trouble with it. (Eg. the variable declaration 'char(*(*x[3])())[5]'.
>> The name of the variable can be found lurking in that lot somewhere, but
>> what's the type?) Not so convenient.
> 
> I believe the type of any variable in C is the same as its declaration,
> but with the variable name deleted.

Yes, I think we got that...

> So:
> 
>      char (*(*[3])())[5]

..which doesn't help, and in fact makes things worse, as now you don't 
have a start point at which to start unravelling it. You have to do it 
from the inside out.

> That is, an array of 3 pointers to functions that return pointers to
> arrays of 5 characters.

But you left out the dozen steps needed to get from that to this!

Anyway if such a type can be more clearly expressed like this, why 
doesn't a language simply allow that, or near enough? Why does it need 
to be cryptic, or require an external tool to encode and decode (there 
is a reason that CDECL exists) or require the programmer to apply an 
algorithm?

-- 
bartc



More information about the Python-list mailing list