lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Miles Bader wrote:
> Mike Pall <mikelu-1102@mike.de> writes:
> > In C++ one would use templates for that purpose. This instantiates
> > a copy of the whole code for a specific number of dimensons.
> > That's not as wasteful as it sounds, since you probably only ever
> > use a finite set of dimensions, e.g. dim=2 and dim=3
> 
> To be fair, gcc at least will happily unroll small fixed loops like
> this, and usually does, to the extent that I've stopped trying to use
> any kind of special technique, and just write the obvious loops when
> programming in C++.

Only if the loop count is known to be constant. But it isn't here,
since it's user-specified.

--Mike