Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
PixelToast

Thoughts on Lua 5.3

Recommended Posts

mXzUxvi.png


Lua 5.3 is still in the "what the hell do we add" stage but you can find the source here: http://www.lua.org/work/
or windows binaries made with MinGW: https://dl.dropboxus.../lua53work2.zip

It is almost identical to 5.2 but has some major things we have all wanted like integers, bitwise operators, and utf8 support
the list is small but here are the changes from 5.2: http://www.lua.org/work/doc/#changes

Main changes:

  • support for integers (64-bit by default)
  • better support for small architectures ("Small Lua" with 32-bit numbers)
  • bitwise operators
  • basic utf-8 library
  • utf-8 escapes in literal strings
  • functions for packing/unpacking numbers
  • userdata can have any Lua value as uservalue
  • strip option in lua_dump/string.dump

Lua standalone interpreter:

  • Can be used as calculator; no need to prefix with '='

kQAHZ1w.png

 

i can probably compile this for OC, give me a bit.

Link to post
Share on other sites

I don't know. I don't dislike it, let me start with that, but I hope they won't break compatibility again. 

And apart from the bitwise operators, it doesn't really add that much. Unless I misunderstand the pack/unpack functions for numbers. 

 

What I would like to see are macros, those would be nice. And a __type metafield. 

Link to post
Share on other sites

i can probably compile this for OC, give me a bit.

If you're really serious about this, I'd recommend looking into making an addon mod for OC that provides a Lua 5.3 computer. You'd need:
  • The compiled Lua 5.3 library, of course.
  • Glue code to access it from Java (pretty sure JNLua won't work).
  • Register an Architecture with OC.
  • In your TileEntity/Environment create a machine using that architecture.
    • Simple case: provide the machine node as the TileEntity's node (this is what the built-in computer cases do).
    • Call the machine's update() from the TileEntity's updateEntity().
  • And quite possibly provide a customized ROM.
Which seems like a lot of work for a work-in-progress version of the same language, that doesn't provide *that* many new features, yet.

But I wanted to raise awareness of this functionality being in the OC API, hoping that somebody will be crazy enough to mess with it at some point ;)

Link to post
Share on other sites

Here is how the integer system works:

cUkL1fa.png

numbers are ints if they dont have a decimal point, otherwise they are floats

this isnt compatability breaking though, the math operators automatically convert them

there is also the new // operator which does division on ints, basically math.floor(a/b)

the reason for this is that we can now divide huge numbers, ones that are too big for floats

G3Twh2o.png

also, all numbers are 64 bit, even when compiled 32 bit

here are all the new bitwise operators:

  • band: a & b
  • bor: a | b
  • bxor: a ~ b
  • bnot ~ a -- not sure how this one works
  • blshift: a << b -- same as a*(2^ B)
  • brshift a >> b -- same as a//(2^ B)
i hope they add a+=b, a++, etc
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.