Skip to content

Instantly share code, notes, and snippets.

@ibanezmatt13
Created September 3, 2013 20:54
Show Gist options
  • Save ibanezmatt13/6429432 to your computer and use it in GitHub Desktop.
Save ibanezmatt13/6429432 to your computer and use it in GitHub Desktop.
[21:43] <eroomde_> ibanezmatt13: have you used excel before?
[21:43] <ibanezmatt13> yea
[21:44] <adamgreig> I feel like a superb analogy is about to come up
[21:44] <ibanezmatt13> :)
[21:44] <eroomde_> so you know when you do equations, you might need to reference the contents of another cell
[21:44] <eroomde_> B4 or whatever
[21:44] <mfa298> adamgreig: I have the same issues at times (mostly for the same reason of not doing it enough)
[21:44] <ibanezmatt13> yes
[21:45] <eroomde_> so you would say '= B4 + 2'
[21:45] <eroomde_> say
[21:45] <ibanezmatt13> ok
[21:45] == chris_99 [~chris_99@unaffiliated/chris-99/x-3062929] has joined #highaltitude
[21:45] <eroomde_> if you wanted to add 2 to whatever was in B4
[21:45] <ibanezmatt13> right
[21:45] == PD2MST [[email protected]] has quit [Quit: 73, de PD2MST]
[21:45] <adamgreig> this is where you realise what pointers are, ibanezmatt13
[21:45] <eroomde_> just as a random example
[21:46] <eroomde_> what does excel do when it sees '= B4 * 2'
[21:46] <eroomde_> ?
[21:46] <adamgreig> there must be some cute diagrams
[21:46] <ibanezmatt13> it multiplies the contents by 2?
[21:46] <eroomde_> er, '= B4 + 2'
[21:46] <ibanezmatt13> adds 2?
[21:46] <eroomde_> ibanezmatt13: it multiplies the contents by 2?
[21:46] <eroomde_> the contents of what?
[21:46] <ibanezmatt13> the cell
[21:46] == Chris_M6CSV [52085b0a@gateway/web/freenode/ip.82.8.91.10] has quit [Client Quit]
[21:47] <ibanezmatt13> b
[21:47] <ibanezmatt13> 4
[21:47] <eroomde_> so what is b4?
[21:47] <ibanezmatt13> a cell :/
[21:47] <eroomde_> yep
[21:47] <eroomde_> it's also
[21:47] <ibanezmatt13> a register?
[21:47] <eroomde_> drumroll
[21:47] <eroomde_> A POINTER
[21:47] <ibanezmatt13> :(
[21:47] <eroomde_> a pointer just tells you where to find what you want in memory
[21:47] <eroomde_> it's an address
[21:48] <eroomde_> i'm making a tiny simplification here to do with types but nvm for now
[21:48] <ibanezmatt13> o-k
[21:48] <daveake> Stick your finger on the screen so it covers the B4 cell. See, you've made your arm into a pointer
[21:48] <eroomde_> when you say 'B4' what you mean is 'whatever is in the cell that is labelled B4'
[21:48] <daveake> now wave it about
[21:48] <ibanezmatt13> ok
[21:49] <eroomde_> you don't want '= B4 + 2' to evaluate to 'B42' or something silly like that
[21:49] <adamgreig> (unless you're using PHP)
[21:49] <eroomde_> you want excel to go and look up what is inside B4 and add 2 to that
[21:49] <eroomde_> that's all pointers are
[21:49] <ibanezmatt13> ok, so you point to B4
[21:49] <eroomde_> they point to a bit of memory
[21:49] == r2x0t [[email protected]] has left #highaltitude []
[21:49] <ibanezmatt13> go get me some info from location b4
[21:49] <ibanezmatt13> kind of thing
[21:49] <eroomde_> yes exactly
[21:49] <eroomde_> that's exactly it
[21:50] <ibanezmatt13> So what's the crack?
[21:50] <eroomde_> that's it
[21:50] <eroomde_> so
[21:50] <eroomde_> *MSG is a pointer
[21:50] <ibanezmatt13> ok
[21:50] <eroomde_> to the start of the bit of memory that has a bunch of bytes in it that is your message
[21:51] <ibanezmatt13> ok
[21:51] <adamgreig> http://www.stanford.edu/~fringer/teaching/operating_systems_03/handouts/lecture9.pdf has some diagrams
[21:51] <adamgreig> though I'm not sure they're the best possible diagrams
[21:51] <adamgreig> some simple C code might demonstrate the concept too
[21:51] <ibanezmatt13> so why is int MSG different to * MSG?
[21:51] == Boggle [[email protected]] has quit [Remote host closed the connection]
[21:51] <eroomde_> because MSG is the name of one single byte somewhere
[21:51] <eroomde_> 4
[21:51] <eroomde_> 97
[21:51] <eroomde_> whatever
[21:52] <ibanezmatt13> ok, and *MSG is?
[21:52] <eroomde_> int *MSG is a pointer to some number of bytes in a row somewhere in memory
[21:52] <eroomde_> [1,2,3,4,5,6,7,8]
[21:52] <eroomde_> ^---- *MSG
[21:52] <ibanezmatt13> o-k
[21:52] <eroomde_> is pointed at 1
[21:53] <eroomde_> *(MSG + 1) is pointed at 2
[21:53] <eroomde_> *(MSG + 2) is pointed at 3
[21:53] <ibanezmatt13> ok
[21:53] <mfa298> the key bit is the * which effectivly means "look at the memory at the address i've got here"
[21:53] <adamgreig> stepping back a moment
[21:53] <ibanezmatt13> ok, I'm going to save this window to a text file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment