[ale] [OT] Anyone up for a 90 Day Wonder Challenge?

Ed Cashin ecashin at noserose.net
Thu Dec 3 09:40:33 EST 2015


I wasn't thinking of memory management (although I agree that adopting
conventions helps avoid errors in that domain).

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:

http://meta.slashdot.org/story/12/10/11/0030249/linus-torvalds-answers-your-questions


... when he talks about linked list operations.  Here's a quote:

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

if (prev)
prev->next = entry->next;
else
list_head = entry->next;

and whenever I see code like that, I just go "This person doesn't
understand pointers". And it's sadly quite common.

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".





On Thu, Dec 3, 2015 at 9:03 AM, DJ-Pfulio <djpfulio at jdpfu.com> wrote:

> Pointers are easy.
>
> Either they point to valid, allocated memory (or a function), or they
> point to
> NULL. PERIOD.  A null pointer exception is much nicer than any bug that
> seems to
> work.
>
> char* myName=NULL;
>
> myName = malloc( sizeof("1234546789") );
> if ( NULL == myName ) return;  /* Always validate the desired memory
> allocation
> worked */
>
> /* do something interesting ; pass myName around, into functions, etc ....
> */
>
> free(myName);
> myName=NULL;
>
> /* Any attempts to reference myName now will provide a null pointer
> exception
> and crash (throw exception). */
>
> BTW, I haven't written any C code that uses malloc() since .... 1995-ish,
> so
> don't expect that to compile cleanly.  Writing clear C code is VERY
> important.
> Sure, there are wasted statements, but there is a reason. Clarity. A good
> compiler will optimize out any wasted code. Some of this code will be
> running in
> 50 yrs, perhaps longer. Make the source clear, always.
>
> I don't expect a SmartPtr class to manage memory for me. They tend to do
> things
> when I don't want and do it in a way different from what I'd like.
>
> Simple. Good pointer management is an important skill for all programmers,
> even
> python, java, and other languages that don't provide direct access to
> pointers.
>  After all, what is a reference?  It is just a pointer.  Perl has
> references and
> they are used ALL-THE-TIME.
>
>
> On 12/03/2015 08:22 AM, Ed Cashin wrote:
> > For some reason this statement reminded me that there was a critical
> > supplement to all the C books I read.
> >
> > Ted Jensen's pointer tutorial:
> >
> >   http://pw1.netcom.com/~tjensen/ptr/pointers.htm
> >
> > ... will eliminate any residual discomfort with pointers.  It's a gem.
> >
> >
> >
> > On Wed, Dec 2, 2015 at 3:05 PM, Boris Borisov <bugyatl at gmail.com> wrote:
> >
> >> I guess everybody is reading their C books. So quiet:)
> >>
> >> On Wednesday, December 2, 2015, Scott M. Jones <eff at dragoncon.org>
> wrote:
> >>
> >>> talky.io claims to do screen sharing.  That's why I'd like to test to
> >>> see how well it works, and if it works at all for bare metal Linux.
> >>>
> >>> https://about.talky.io
> >>>
> >>>
> >>>
> >>> On 12/2/15 11:30 AM, DjPfulio wrote:
> >>>>
> >>>> The problem with web RTC is its only webcam based; how do we share
> >>>> screens through it? that's the problem.
> >>>>
> >>>> On 2 December 2015 10:08:09 GMT-05:00, "Scott M. Jones"
> >>>> <eff at dragoncon.org> wrote:
> >>>>
> >>>>     On 11/26/15 6:41 AM, Leam Hall wrote:
> >>>>
> >>>>         Soo...Scott, does that mean you're volunteering to be a
> resident
> >>>>         mentor? :P
> >>>>
> >>>>
> >>>>     I'd be interested in helping to the extent that I can.  We went to
> >>> C++
> >>>>     in 2001 and Java in 2006, and sinc>     options.  One possibility
> >>> not mentioned so far is talky.io <http://talky. <http://talky.io>>
> >>> __________
> >>
> >>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
  Ed Cashin <ecashin at noserose.net>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ale.org/pipermail/ale/attachments/20151203/23586710/attachment.html>


More information about the Ale mailing list