Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Every variable is a starting memory address to the compiler.

Definitely not true. More like, "it will have an address, if you take the address with the & operator". Otherwise, the compiler is quite free to store locals in registers.



> Yes I am being simplistic and yes certain data types have certain syntactic sugar but I have found this to be a good mental model

As stated in the post.


I think you're going to keep getting comments on these ill-considered asides, but here is another problem:

"In most assembly languages, data types don’t exist. You operate on bytes and offsets."

This is just not true.

Most assembly languages (I learned on PDP-11 assembler, which I remember best, but what I say is true of 68000 and x86 too) have a notion of a byte, but also integers of various word lengths, and floating point numbers.

In fact, some registers are in effect designated as "pointers" for various kinds of conventional indirect addressing (the instruction pointer, the register holding the stack pointer, and others).

In this sense, C is even closer to assembly than you indicate, because the data types are so analogous.


This reminds me of another comment I had: I personally find the phrase "syntactic sugar" irritating. As used, I don't feel like it adds anything to the blog post. IMO you could write nothing there and it'd make the exact same point.

What exactly is the "syntactic sugar" that hides the idea that names can have addresses? Structs? Some specific kind of expression? Array index syntax? The names themselves?


Simplicity here doesn't help. Variables aren't about how they are stored and where but more about what gets applied to them and how.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: