lua-users home
lua-l archive

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


> > Can't you use #string.pack(fmt, ...), with specific dummy arguments?
> 
> 0 works everywhere except c[n], which needs the exact length to match.
> 
> But "hard to implement in Lua" is fair also for the dummy argument
> approach. You need to be able to generate a list `0,0,0,0,...` of at least
> the right length, punctuated by the occasional string.rep(' ',n). This
> amounts to parsing `fmt` in Lua.

I was not proposing a "generic" implementation for pack size, just a
simple way to compute the size of a supposely known format. (Anyway,
even the offical size function from the struct library does not work for
all formats...)

-- Roberto