lua-users home
lua-l archive

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


On Thu, Mar 12, 2009 at 5:09 PM, duck <duck@roaming.ath.cx> wrote:
> However, my initial zest to see this feature implemented has evaporated.
> After all, as LHF suggested but I originally refuted, it *is* bloat (being
> unnecessary since there already exists a way of embedding arbitrary bytes
> in strings), no matter that it is small bloat. And as someone else pointed
> out, lots of small bloats make a big bloat :-)

LHF's suggestion is to replace a compile-time string literal with a
run-time function that takes a string literal and creates a new
string.  There are costs to doing that.  Of the top of my head:

1.  The original string literal resides in the compiler's constant
table, and never gets reclaimed.  So a string with many escapes (say
as in embedded an image or other binary data) not only uselessly takes
up memory, it's memory that can't be recovered.

2.  The function that transforms the string literal takes some
non-zero amount of time to process.  Typically this is going to be a
call to gsub.  That's generally pretty efficient, but still far more
expensive than a LOADK instruction.  Consider what happens if the
transformation function is called inside a loop that executes many
times.

So I reject the bloat argument here because the cost of incorporating
this feature in Lua is far less than the cost for users of the
language to build up the same functionality.

I also reject the bloat argument as it suffers from the same issue
many arguments based on "slippery slopes" have.  Roberto wrote:

 > (If each group of 20 users [or 200, for that matter] would
 > have its own 10 lines of code, Lua would end really
 > bloated.)

This is a lot like saying that if all the runners in a marathon all
had exactly the same gait, they could take out a bridge by running
across it.  But that would assume all the runners had the same stride,
the same speed, and the same phase.  In reality, that never happens.
And likewise, while there may be various groups in the Lua community
who are each advocating changes to the language, not all of those
changes have equal merit.  This mailing list has had great ideas from
experienced Lua users who advocated changes that did make it into the
language.  This mailing list also has newbies to Lua who advocate
changes that are some combination of arbitrary, aesthetic, or just
plain bizarre.  So not all groups advocating for a change to Lua are
on equal ground and fears that each group is going to add their own
"bloat" to Lua are unfounded.

> Plus I just took into account that despite all my years doing low-level
> stuff on PCs, I can still count (and add, and definitely multiply) in my
> head far better in decimal than any other base...

Different purposes.  Counting is decimal.  Injecting characters with
specific bit patterns is best with hexadecimal.  Nobody (I hope) is
suggesting that because hexadecimal is a natural number base for
working with bits that it is a natural number base for working with
*everything*.