Stepping back and looking at constness from another angle.

Bill Baxter dnewsgroup at billbaxter.com
Mon Jun 4 20:29:46 PDT 2007


Jarrett Billingsley wrote:
> "Bill Baxter" <dnewsgroup at billbaxter.com> wrote in message 
> news:f42c51$1ap8$1 at digitalmars.com...

>> The crux there is that I really don't care how it gets passed under the 
>> hood as long as it's efficient and behaves as if it were passed by value.
> 
> I really like that idea.  It also implicitly reduces maintenance.  If today, 
> passing a 16-byte struct on the stack is more efficient to pass by 
> reference, or if a struct doesn't fit in a register, but five years from now 
> that's no longer the case, we don't have to go around removing all the refs 
> to improve performance.  The compiler knows what's better.

I suspect the main problem with it is just that it makes a prototype 
alone insufficient for determining how to call a function.  Probably not 
an insurmountable problem, but probably difficult enough to make it not 
worth it.  For instance if you could have meta-info about functions in 
obj files and modify the linker to use it, then probably it's no prob. 
But that's a big if.  And it still doesn't give you reference object 
constness.

--bb



More information about the Digitalmars-d mailing list