Coder Social home page Coder Social logo

Comments (13)

siffiejoe avatar siffiejoe commented on May 28, 2024

@hishamhm, @daurnimator, @zhaozg

The table library is almost complete (only table.sort missing for now). More tests are welcome! However, since pretty much every function in the table library has to be replaced anyway, we could use the same approach as for the utf8 module, and just use ltablib.c from the Lua 5.3 sources as is (I'd just have to turn the lua_rawget/lua_rawset macros from the c-api into real functions). On the other hand, the utf8 functions could probably be implemented in pure Lua, too.

What do you think?

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 28, 2024

Never mind (there is a problem with Lua 5.1 not respecting the __len metamethod on tables), the table library stays in pure Lua for now.

from lua-compat-5.3.

daurnimator avatar daurnimator commented on May 28, 2024

Never mind (there is a problem with Lua 5.1 not respecting the __len metamethod on tables), the table library stays in pure Lua for now.

Why does that matter?

You can always check __len from C...

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 28, 2024

You can always check __len from C...

But the source code of the table library didn't (or rather our lua_len implementation for Lua 5.1 didn't). I changed that, so the option of using ltablib.c from the 5.3 sources is on the table again (no pun intended).

Anyhow, table.sort in pure Lua is available as well by now.

from lua-compat-5.3.

hishamhm avatar hishamhm commented on May 28, 2024

Well, since parts are already written in C, I don't see a problem in having it either in C or Lua.

Speaking of tests, a crazy idea would be to see how much of the standard Lua test suite for 5.3 one would be able to run in an earlier version using compat :)

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 28, 2024

Well, since parts are already written in C, I don't see a problem in having it either in C or Lua.

That's the point, I think utf8 could be implemented in pure Lua as well (string packing is another story, though) ...
Is there a reason to prefer Lua code over C code (for the user of compat53)?

from lua-compat-5.3.

hishamhm avatar hishamhm commented on May 28, 2024

@siffiejoe I don't know... Windows users who shudder at the idea of setting up a build environment and compiling C code?

Ah, and pure-Lua might run faster for LuaJIT users, but further tests would be required.

from lua-compat-5.3.

daurnimator avatar daurnimator commented on May 28, 2024

I can imagine people wanting to use pure lua libraries inside a game or framework where they can't load C code...

For my use cases, I don't really care/mind; I mainly use the project for new C functions :P

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 28, 2024

Most table functions aren't compiled in LuaJIT anyway, so I've added ltablib.c from the Lua 5.3 sources as a C module. I'll keep the pure Lua code as a fallback in case loading the C module fails.

(I think users of a game or a framework are stuck with one specific Lua version most of the time, so a compatibility module makes no sense for them ...)

from lua-compat-5.3.

daurnimator avatar daurnimator commented on May 28, 2024

(I think users of a game or a framework are stuck with one specific Lua version most of the time, so a compatibility module makes no sense for them ...)

I was imagining someone wanting to use a general pure lua module (e.g. luatz), that might be written against new apis (e.g. table.move): the user might be stuck on lua5.1, so they load compat-5.3 first?

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 28, 2024

Point taken.

from lua-compat-5.3.

siffiejoe avatar siffiejoe commented on May 28, 2024

We now have string packing as a binary module, so I'll leave the binary utf8 module alone as well.

Running the Lua 5.3 test suite proves to be rather complicated: I had to disable test code with integer division operators, bit operators, large integers, and utf-8 escape sequences. The table, utf8, and string packing functions pass the remaining tests, but those are the pieces that I took from the Lua 5.3 sources almost unmodified. Testing the rest this way is too much work for me at the moment ...

I think I'm done for now, so I'll change to a more reactive mode of development.

from lua-compat-5.3.

hishamhm avatar hishamhm commented on May 28, 2024

@siffiejoe wow, awesome!! I guess this means it's time to tag it 0.1 and announce it to lua-l, then. Will you do the honors? :)

from lua-compat-5.3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.