lua-users home
lua-l archive

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


On Sat, Aug 23, 2014 at 12:54 AM, Sean Conner <sean@conman.org> wrote:

>> >   Okay, now I'm totally confused as to what you are trying to do.  Let's
>> > take, for example, LPeg.

Why would you turn to LPeg for an understandable example? 0.o

>   Um.  So what should #f return in this case?  The size of the file?  Works
> fine for real files, but how about
>
>         f = io.open("/dev/zero","r")

This would be a moment for rawlen() if I wanted to get the FILE struct
size within the userdata :>  Getting the size of the file itself would
be done with the file:seek() function.

> What does
>
>         x = lpeg.P "Coroutines"
>         print(#x)
>
> even mean?

Well if LPeg defines a __len for that you trigger that -- otherwise I
think it returns a userdata so that'd be the byte size?

>> I want to be able to string.sub() userdata, so I can read
>> character-by-character.  Promoting a lua_Buffer/userdata to a string
>> hashes the userdata and from then on it's known as a string to Lua, and I
>> cannot modify it.
>
>   Okay, you are definitely associating "userdata" with "large, growable
> character array".  userdata is more than just that.

Userdata is 2 tables + commonheader? + data -- it seems very close to
a character array to me :>

>   The Amiga did zero-copy message passing.  Upside:  it was quick.
> Downsides:

I did read through the rest of your post but I feel like it's
attacking what I want to do with userdata, not if userdata should be
readable as strings in some way.  "We shouldn't have that because you
can do something bad!"  Maybe you would be so kind as to let me reap
my own rewards/failtures? :>  I do understand the risks of doing this
incorrectly.

PS: I have never used a microkernel, I do not know of this inherent
message-passing you speak of.  Also, I'm pretty sure people who do #3
would resort to #2 to make that zero-copy.  You know lock-free
algorithms are still a thing... a queue within a queue within a queue
is good on you :D