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 Sat, Aug 23, 2014 at 12:11 AM, Sean Conner <sean@conman.org> wrote:
> 
> >   It doesn't bother me, because the convenience it affords is worth the
> > price (in my opinion).
> 
> What convenience?  I'm saying the interface doesn't exist to make
> mutable data (userdata) as accessible as immutable, pooled strings.

  The convenience of string manipulations.  
  
> >   I swear, the way you are talking, it's as if you equate "userdata" with
> > "Lua's internal string representation" and it jars me every time.  I have
> > plenty of userdata types that have nothing to do with strings; where
> > "userdata == string" just does not make any semamtic sense what-so-ever [1].
> 
> I should word this more carefully: I mean to say that userdata and
> strings (the internal structures and how they are handled in Lua) are
> very similar.

  And in C, structures and strings are similar as well (a continuous
sequence of bytes) but heaven help you if you mix the two up.

> >   I use 22 userdata types at work (just counted).  It's not a small concern.
> 
> I mean to say -- how  many of those are you defining personally?  

  22.  And I now realized I forgot a few from some third party code I'm also
using.  So, say, 25 or 26.

> How
> many are brought in from third-parties?  I don't think you'd have much
> problems deciding the names for each..

  No, for the ones I defined, the names are based off the module they're in,
so I have (for example):

	org.conman.net:addr
	org.conman.net:sock
	org.conman.signal:sigset
	org.conman.fsys:dir
	org.conman.fsys:expand

  It doesn't bother me that they're long, because 1) they're #defined in the
C code and 2) that's the only place they're exposed (except you can see them
in the registry with debug.getregistry() from Lua).

> Related: It would be nice to be able to change the typename at runtime
> (even so that checkudata passes) -- without having to recompile the
> third-party library that defines the userdata type.

  Good lord!  Is there nothing you don't want to change?  Yes, I realize
that every computer science problem can be solved by another layer of
indirection [1] but it does slow things down.

> >   I never said it was static.  That "buffer" there is an auto---declared on
> > the stack of the socklua_recv() function [5].  No static buffer here.
> 
> My bad, I thought I read static :\  Stack overflows are fun... :p  I
> was just thinking offhandedly that you could create a mmap, expose it
> to Lua as a file to read and write from -- and pass it to the
> networking lib as the buffer to recv into.  

  Um, you map files into memory with mmap().  You can also mmap() memory
without a file to allocate memory.  You do one or the other.

> Hmm.  And it could be
> shared depending on the threading setup -- but that's an afterthought.

  By definition, all threads in a process share memory; there's nothing to
set up.  It's sharing memory among processes that's tough.

  -spc

[1]	"All problems in computer science can be solved by another level of
	indirection." --Butler Lampson