<div dir="ltr">I wasn't thinking of memory management (although I agree that adopting conventions helps avoid errors in that domain).<div><br></div><div>I'm thinking of the difference between truly grokking the power of multiple levels of read-write indirection. A deep comfort with the use of pointers is what Linus Torvalds was talking about here:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions">http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions</a></div></blockquote><div><br></div><div>... when he talks about linked list operations. Here's a quote:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">At the opposite end of the spectrum, I actually wish more people understood the really core low-level kind of coding. Not big, complex stuff like the lockless name lookup, but simply good use of pointers-to-pointers etc. For example, I've seen too many people who delete a singly-linked list entry by keeping track of the "prev" entry, and then to delete the entry, doing something like</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">if (prev)</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">prev->next = entry->next;</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">else</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">list_head = entry->next;</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">and whenever I see code like that, I just go "This person doesn't understand pointers". And it's sadly quite common.</span><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><br style="margin:0px;padding:0px;color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px"><span style="color:rgb(54,54,54);font-family:Arial,sans-serif;font-size:13px;line-height:19.5px">People who understand pointers just use a "pointer to the entry pointer", and initialize that with the address of the list_head. And then as they traverse the list, they can remove the entry without using any conditionals, by just doing a "*pp = entry->next".</span><div> </div></blockquote><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 3, 2015 at 9:03 AM, DJ-Pfulio <span dir="ltr"><<a href="mailto:djpfulio@jdpfu.com" target="_blank">djpfulio@jdpfu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pointers are easy.<br>
<br>
Either they point to valid, allocated memory (or a function), or they point to<br>
NULL. PERIOD. A null pointer exception is much nicer than any bug that seems to<br>
work.<br>
<br>
char* myName=NULL;<br>
<br>
myName = malloc( sizeof("1234546789") );<br>
if ( NULL == myName ) return; /* Always validate the desired memory allocation<br>
worked */<br>
<br>
/* do something interesting ; pass myName around, into functions, etc .... */<br>
<br>
free(myName);<br>
myName=NULL;<br>
<br>
/* Any attempts to reference myName now will provide a null pointer exception<br>
and crash (throw exception). */<br>
<br>
BTW, I haven't written any C code that uses malloc() since .... 1995-ish, so<br>
don't expect that to compile cleanly. Writing clear C code is VERY important.<br>
Sure, there are wasted statements, but there is a reason. Clarity. A good<br>
compiler will optimize out any wasted code. Some of this code will be running in<br>
50 yrs, perhaps longer. Make the source clear, always.<br>
<br>
I don't expect a SmartPtr class to manage memory for me. They tend to do things<br>
when I don't want and do it in a way different from what I'd like.<br>
<br>
Simple. Good pointer management is an important skill for all programmers, even<br>
python, java, and other languages that don't provide direct access to pointers.<br>
After all, what is a reference? It is just a pointer. Perl has references and<br>
they are used ALL-THE-TIME.<br>
<span class=""><br>
<br>
On 12/03/2015 08:22 AM, Ed Cashin wrote:<br>
> For some reason this statement reminded me that there was a critical<br>
> supplement to all the C books I read.<br>
><br>
> Ted Jensen's pointer tutorial:<br>
><br>
> <a href="http://pw1.netcom.com/~tjensen/ptr/pointers.htm" rel="noreferrer" target="_blank">http://pw1.netcom.com/~tjensen/ptr/pointers.htm</a><br>
><br>
> ... will eliminate any residual discomfort with pointers. It's a gem.<br>
><br>
><br>
><br>
> On Wed, Dec 2, 2015 at 3:05 PM, Boris Borisov <<a href="mailto:bugyatl@gmail.com">bugyatl@gmail.com</a>> wrote:<br>
><br>
>> I guess everybody is reading their C books. So quiet:)<br>
>><br>
>> On Wednesday, December 2, 2015, Scott M. Jones <<a href="mailto:eff@dragoncon.org">eff@dragoncon.org</a>> wrote:<br>
>><br>
>>> <a href="http://talky.io" rel="noreferrer" target="_blank">talky.io</a> claims to do screen sharing. That's why I'd like to test to<br>
>>> see how well it works, and if it works at all for bare metal Linux.<br>
>>><br>
>>> <a href="https://about.talky.io" rel="noreferrer" target="_blank">https://about.talky.io</a><br>
>>><br>
>>><br>
>>><br>
>>> On 12/2/15 11:30 AM, DjPfulio wrote:<br>
>>>><br>
>>>> The problem with web RTC is its only webcam based; how do we share<br>
>>>> screens through it? that's the problem.<br>
>>>><br>
>>>> On 2 December 2015 10:08:09 GMT-05:00, "Scott M. Jones"<br>
>>>> <<a href="mailto:eff@dragoncon.org">eff@dragoncon.org</a>> wrote:<br>
>>>><br>
>>>> On 11/26/15 6:41 AM, Leam Hall wrote:<br>
>>>><br>
>>>> Soo...Scott, does that mean you're volunteering to be a resident<br>
>>>> mentor? :P<br>
>>>><br>
>>>><br>
>>>> I'd be interested in helping to the extent that I can. We went to<br>
>>> C++<br>
>>>> in 2001 and Java in 2006, and sinc> options. One possibility<br>
</span>>>> not mentioned so far is <a href="http://talky.io" rel="noreferrer" target="_blank">talky.io</a> <<a href="http://talky" rel="noreferrer" target="_blank">http://talky</a>. <<a href="http://talky.io" rel="noreferrer" target="_blank">http://talky.io</a>>><br>
>>> __________<br>
<div class="HOEnZb"><div class="h5">>><br>
>><br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" rel="noreferrer" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"> Ed Cashin <<a href="mailto:ecashin@noserose.net" target="_blank">ecashin@noserose.net</a>></div></div>
</div>