Python Front-end to GCC

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Oct 25 16:14:13 EDT 2013


[sorry if things below are a bit messy]

On 25/10/2013 20:49, Mark Janssen wrote:
>>>> As for the hex value for Nan who really gives a toss?  The whole point is
>>>> that you initialise to something that you do not expect to see.  Do you
>>>> not have a text book that explains this concept?
>>>
>>> No, I don't think there is a textbook that explains such a concept of
>>> initializing memory to anything but 0 -- UNLESS you're from Stupid
>>> University.
>>>
>>> Thanks for providing fodder...
>>
>> We've been discussing *DEBUGGING*.
>
> Are you making it LOUD and *clear* that you don't know what you're
> talking about?
>
> Input:  Yes/no

no

Now please explain what you do not understand about the data below 
that's been written by Oscar Benjamin, myself and Ned Batchelder, 
specifically the use of the word *DEBUGGING*.  Is this a word that does 
not appear in your text books?  If that is in fact the case would you 
like one of the experienced practical programmers on this list to 
explain it to you?  Have you ever bothered to read "The Zen of Python", 
specifically the bit about "Practicality beats purity"?

>
> MarkJanssen
>

On 25/10/2013 04:40, Mark Lawrence wrote:> On 22/10/2013 18:37, Oscar 
Benjamin wrote:
 >
 >>
 >> OTOH why in particular would you want to initialise them with zeros? I
 >> often initialise arrays to nan which is useful for debugging. It means
 >> that you can see if you made a mistake when you were supposed to have
 >> initialised everything to useful values. In many contexts it would be
 >> difficult to distinguish between a valid zero and a zero because you
 >> haven't yet inserted a value. This kind of error can show up more
 >> quickly if you don't zero the memory since the uninitialised values
 >> will often be out of range for what you expected and will give very
 >> noticeable results (such as a seg-fault).
 >>
 >
 > In his book "Writing Solid Code" Steve Maguire states that he
 > initialises with 0xA3 for Macintosh programs, and that Microsoft uses
 > 0xCC, for exactly the reasons that you describe above.
 >

On 25/10/2013 15:35, Ned Batchelder wrote:> On 10/25/13 7:55 AM, Mark 
Janssen wrote:
 >> On Thu, Oct 24, 2013 at 8:40 PM, Mark Lawrence
 >> <breamoreboy at yahoo.co.uk> wrote:
 >>> On 22/10/2013 18:37, Oscar Benjamin wrote:
 >>>> OTOH why in particular would you want to initialise them with zeros? I
 >>>> often initialise arrays to nan which is useful for debugging.
 >> Is this some kind of joke?  What has this list become?
 >>
 >
 > It's a useful debugging technique to initialize memory to distinctive
 > values that should never occur in real data.  Perhaps it better to say,
 > "pre-initialize".  If the program is working correctly, then that data
 > will be written over with actual initial values, and you'll never see
 > the distinctive values.  But if your program does encounter one of those
 > values, it's clear that there's a bug that needs to be fixed.
 > Additionally, if you have a number of different distinctive values, then
 > the actual value encountered provides a clue as to what might have gone
 > wrong.
 >
 > In an array of floats, initializing to NaN would be very useful, since
 > NaNs propagate through calculations, or raise exceptions.
 >
 > --Ned.


-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence




More information about the Python-list mailing list