Jump to content




Lua rants, because we all love it!


30 replies to this topic

#21 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 12 January 2015 - 07:44 PM

I suspect LuaJ has all the native Lua libraries built-in. But like I said, a lot of Lua libraries can be made in plain CC Lua.

Edited by MKlegoman357, 12 January 2015 - 07:53 PM.


#22 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 12 January 2015 - 09:37 PM

View PostMKlegoman357, on 12 January 2015 - 07:44 PM, said:

I suspect LuaJ has all the native Lua libraries built-in. But like I said, a lot of Lua libraries can be made in plain CC Lua.
What's the point about reinventing the wheel?
anyway, I think Dan has reasons for the removal of those libraries. You'll live without those libraries, they are not life dependant

#23 Agent Silence

  • Members
  • 319 posts
  • Location[string "FindMe"]:23143: bad argument #1 to 'returnPos' (vector expected, got nil)

Posted 12 January 2015 - 09:46 PM

View PostMKlegoman357, on 12 January 2015 - 03:23 PM, said:

Well, from my point of view Lua's 'require' is basically 'dofile' but with a little more functionality for managing libraries. 'dofile' works quite well instead of 'require'.

What I don't like about CC Lua is the lack of not just the debug library but all Lua's libraries. Literally, why CC doesn't have all the default Lua's libraries. In fact almost every library can be recreated in CC Lua so I do not see why, for example, the io library couldn't be completely added and functional in CC. And the package library with 'require'. And the debug library (allowed by config option). Why Dan? Why??
Why does everyone want the debug library? Im confused as to what it does.

#24 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 12 January 2015 - 10:15 PM

So they can break the sandbox more easily. That might not be what it would be used for initially (it does have debugging uses as well), but that's the biggest thing it would be used for after maybe a day at most. We will likely never see it in ComputerCraft.

#25 ElvishJerricco

  • Members
  • 803 posts

Posted 13 January 2015 - 01:10 AM

View PostLyqyd, on 12 January 2015 - 10:15 PM, said:

So they can break the sandbox more easily. That might not be what it would be used for initially (it does have debugging uses as well), but that's the biggest thing it would be used for after maybe a day at most. We will likely never see it in ComputerCraft.

I would love the debug library so that I could, you know, debug. I say it should be a config option so that I can use it for debugging, then distribute a program that doesn't rely on the debug library.

View Postlucy-san, on 12 January 2015 - 02:33 PM, said:

View PostElvishJerricco, on 12 January 2015 - 08:55 AM, said:

My point was more that the + operator can't be changed in the compiler to concatenate strings. I'm aware that Lua code can be written to handle doing either concatenation or addition. It's just that the + operator must equate to an add instruction.
By compiler You mean LuaLua? I haven't read the code, but I'm pretty sure that this can be accomplished in one way or another :)

I mean you could. But doing so would require replacing every add instruction with a series of operations that would ultimately just be very slow.

#26 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 13 January 2015 - 06:22 AM

Certainly it wouldn't hurt to have the debug libraries accessible via config. There'd need to be some warnings attached, though - the typical server owner, if asked by one of their users to enable them, wouldn't have any idea as to the ramifications. Some commented lines in the config should suffice.

View Postlucy-san, on 12 January 2015 - 08:30 AM, said:

Same way You do now?

Those were two mutually exclusive methods. I'm not sure what you're on about. :|

Let's say "local" is abolished, and you have this:

x = 0

for i=1,10 do
  x = x + 1
end

print x

Is the "x" that we're assigning to within the loop local to that loop, or does it refer to the pre-defined upvalue above the loop? That is to say, does the print statement at the end print 0, or does it print 10?

Let's say it's a new local. In that case, how would you make it refer to the upvalue? By constantly sticking an "upvalue" keyword in front of it? You'd end up typing that more often than you have to type "local" now. Re-assignments to upvalues typically occur far more frequently than new declarations.

Let's say it's the upvalue. What options would you have if you wanted to declare a new variable, short of using a unique title every single time? There goes that flexibility - you'd need to make absolutely sure you don't let your names collide.

These aren't insurmountable problems; but I'm not seeing a solution that isn't worse than the original issue.

#27 ElvishJerricco

  • Members
  • 803 posts

Posted 13 January 2015 - 06:30 AM

View PostBomb Bloke, on 13 January 2015 - 06:22 AM, said:

Certainly it wouldn't hurt to have the debug libraries accessible via config. There'd need to be some warnings attached, though - the typical server owner, if asked by one of their users to enable them, wouldn't have any idea as to the ramifications. Some commented lines in the config should suffice.

Yea as it stands, debugging in CC can be a nightmare. I really don't see a reason not have this config option.

#28 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 13 January 2015 - 07:51 AM

View PostElvishJerricco, on 13 January 2015 - 06:30 AM, said:

View PostBomb Bloke, on 13 January 2015 - 06:22 AM, said:

-spoiler-

Yea as it stands, debugging in CC can be a nightmare. I really don't see a reason not have this config option.

I thought about re-implementing some elements with bytecode injection. I started some work here, though most of it doesn't work.

Basic description behind it:
Spoiler

What I don't get though is why emulator developers don't add the option for it, even if we don't have it normal ComputerCraft?

Edited by SquidDev, 13 January 2015 - 07:52 AM.


#29 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 13 January 2015 - 02:05 PM

View PostEngineer, on 12 January 2015 - 09:37 PM, said:

What's the point about reinventing the wheel?
anyway, I think Dan has reasons for the removal of those libraries. You'll live without those libraries, they are not life dependant

But you have to modify most of the external Lua scripts or libraries if you want to include in your scripts. By saying that 'you can write most of the libraries in plain CC Lua' I meant that if it is possible to do it, why didn't Dan include them? I understand why debug library is dangerous but the package library? It would of course be restricted to local .lua files so C libraries couldn't be loaded but why not to include it at all? At the worst all those libraries could have been rewritten as an API just like io library is now. But why to exclude them completely?

Edited by MKlegoman357, 13 January 2015 - 02:06 PM.


#30 lucy-san

  • Members
  • 23 posts
  • LocationPolen

Posted 14 January 2015 - 09:11 AM

View PostBomb Bloke, on 13 January 2015 - 06:22 AM, said:

Those were two mutually exclusive methods. I'm not sure what you're on about. :|

Let's say "local" is abolished, and you have this:

x = 0

for i=1,10 do
  x = x + 1
end

print x

Is the "x" that we're assigning to within the loop local to that loop, or does it refer to the pre-defined upvalue above the loop? That is to say, does the print statement at the end print 0, or does it print 10?

Let's say it's a new local. In that case, how would you make it refer to the upvalue? By constantly sticking an "upvalue" keyword in front of it? You'd end up typing that more often than you have to type "local" now. Re-assignments to upvalues typically occur far more frequently than new declarations.

Let's say it's the upvalue. What options would you have if you wanted to declare a new variable, short of using a unique title every single time? There goes that flexibility - you'd need to make absolutely sure you don't let your names collide.

These aren't insurmountable problems; but I'm not seeing a solution that isn't worse than the original issue.

It should refer to upvalue, just as Python and any other normal language does. Reusing names is not a good coding habit.
In normal case you rarely will have to handle more than handful of variables at once - you will have functions, classes and loops, not spaghetti with gotos.

#31 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 14 January 2015 - 07:36 PM

View Postlucy-san, on 14 January 2015 - 09:11 AM, said:

Reusing names is not a good coding habit.
Yet there has to be accounted for it, because not all people follow conventions





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users