4 ms·
When reading code in a low level setting you may want to know whether one line calls a function or simply reads a field from memory. Not that it would matter th
by zdimension 3y ago
When reading code in a low level setting you may want to know whether one line calls a function or simply reads a field from memory. Not that it would matter that much, but it's a valid point for some. Reading a field is usually expected to not induce any control flow
- gpderetta 3y ago> When reading code in a low level setting you may want to know whether one line calls a function or simply reads a field from memory. Unless you ditch optimizations completely, it is hard to know without looking at the generated asm. Of course you can make educated guesses.
- WalterBright 3y agoThe idea in D is to make the following unnecessary: struct S { int m_field; int field() { return m_field; } void field(int c) { m_field = x; } } just to future proof the field access. Don't bother with the access functions until they are actually needed.
- zozbot234 3y agoThe actual feature that languages should implement is lenses, prisms and optics which are like properties except made properly composable and enabling high-level optimizations, for a similar efficiency to "bare" field access.
- xigoi 3y agoI’ve never heard of those. Do you have a link explaining them?