lua-users home
lua-l archive

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


It was thus said that the Great Coroutines once stated:
> On Fri, Aug 22, 2014 at 3:01 AM, Sean Conner <sean@conman.org> wrote:
> 
> I wish userdata were "enhanced" for more buffer-like activities and
> mutable strings were the norm (hosted off of userdata).  Really I just
> deal with too many third-party libraries that expect strings so I must
> promote userdata to string for these APIs.  [/religious-war-in-the-making]

 Clarification:  by "userdata" do you mean the underlying string-type
userdata, or *any arbitrary* userdata?

> >   Um ... I thought by using immutable data you do less locking, not more, if
> > I understand the functional programmers arguments.  Could you explain how
> > mutable strings leads to *less* locking?
> 
> One of the things I wanted to do a while back was start multiple threads
> from the main process where Lua is embedded.  Then, without locking, index
> _G from different threads so data within the Lua state could be shared in
> a sort of "read only and if you want, modify carefully" schenario.  

  Clarification:  by "thread" do you mean an OS thread, or a Lua coroutine?

> When I
> talked about doing this (Roberto?) said by indexing _G with a string that
> potentially doesn't exist would mean having to lock the state to first add
> the string to the pool within the state (I think this is the global_State
> object?).  

  Yes, along with the registry and GC.

> > I would accept a string.replace() function that doesn't use patterns.  I
> > will not accept an even more complicated string.gsub() function.  Such a
> > proposal is leading to a "candy machine interface" that is hard or
> > troublesome to use [1][2].
> 
> This feels like exaggeration to me -- would my proposal for adding
> another parameter to gsub() honestly be too hard to remember or
> follow?  I almost never find myself using the n-replacements argument,
> few people even realize gsub has a 4th parameter to begin with.  

  Personally, I never use metamethods to implement object inherentance, but
that doesn't mean other people don't do that (they do, all too often it
seems) so saying "few people even realize gsub has a 4th parameter" seems
too much like self-projecting---have you done a formal survey?

> F#ck it, let's just tear out the spaghetti 500 lines of C for patterns and
> hoist in LPeg.  It's a better hammer anyway :-)))

  I know Roberto has been thinking along those lines.

  -spc