Lua-related technology
< prev
1
2
3
4
5
6
...
12 next >
Anonymous >30d ago #p25360 >>quote [AutoMod] action=keep R:9 E:8 N:9 C:9 | This post offers specific, relevant technical suggestions regarding Lua integration with other systems. It directly addresses the thread's theme effectively.
If you use libev as an event loop in your host program you can trivially access it from lua with lua-ev for timers, io watchers etc. Probably works with uv, too.
I'm also a fan of luaposix to access the complete (?) posix C api from lua.
Is there an alternative to luafilesystem? I'm not using it simply because it pollutes the global namespace.
Anonymous >30d ago #p25361 >>quote [AutoMod] action=keep R:9 E:8 N:7 C:9 | This post provides a concise and relevant technical suggestion directly addressing the context. It builds logically on the previous discussion effectively.

screen.png
>>25358
Btw for the specific example you showed, you can just do it out of the box using __index, without all the class boilerplate
Anonymous >30d ago #p25362 >>quote [AutoMod] action=keep R:10 E:8 N:9 C:9 | This post directly addresses a specific technical concern about Lua libraries and global namespace pollution. It is relevant and well-argued.
>>25360
>Is there an alternative to luafilesystem? I'm not using it simply because it pollutes the global namespace.
Does it set a bunch of globals or something?
Anonymous >30d ago #p25363 >>quote [AutoMod] action=keep R:10 E:9 N:8 C:9 | This is a solid, technical response addressing the technical concerns about global namespace pollution in Lua modules. It directly engages with the historical context of Lua's implementation.
>>25362
>Does it set a bunch of globals or something?
It registers the module globally as lfs when require'd. Years ago this also used to break lua_ls, no idea if that is the case anymore.
It won't be fixed because there's probably lots of software that depend on that behavior.
Anonymous >30d ago #p25364 >>quote [AutoMod] action=keep R:8 E:8 N:7 C:9 | The user is asking a technical question about Lua's object model and prototype-based OOP. The critique is sharp and directly addresses the technical validity of the quoted code.
>>25358
>function Object:proto()
> return rawget(self, "__proto")
>end
Does this actually work? There is no self reference anywhere.
I'm too used to just creating closure based classes, even tho it's heavier on memory (if you dont use references to functions instead of creating a new function every time you instance a class)
Anonymous >30d ago #p25365 >>quote [AutoMod] action=keep R:10 E:10 N:9 C:9 | This post is a strong, concise statement that fits the context of a technical discussion. It directly addresses the perceived superiority of Lisp and pivots to Python/C/ASM optimization.
lisp lost, therefore nothing else matters besides python + optimized c/asm functions
Anonymous >30d ago #p25366 >>quote [AutoMod] action=keep R:8 E:7 N:6 C:8 | The post offers a specific, albeit slightly pedantic, critique of Lua's syntax. It engages directly with the quoted context effectively.
>>25364
NTA but it's gay syntactic sugar, if you define a function with the colon syntax after the function keyword like
>function foo:bar() end
It automatically implies a first parameter called self.
Anonymous >30d ago #p25367 >>quote [AutoMod] action=keep R:10 E:9 N:8 C:9 | The explanation is concise and directly addresses the technical point. It effectively clarifies the syntactic sugar in a very sophisticated way.
>>25364
It works because Object:proto() is sugar for Object.proto(self) (note the : vs .)
Anonymous >30d ago #p25368 >>quote [AutoMod] action=keep R:8 E:7 N:6 C:9 | The user is engaging in a technical discussion about Lua syntax and object-oriented concepts. The post is relevant and well-argued within the context of the thread.
>>25366
>>25367
Oh, i see. Usually I do this
function f(s)
end
local a = {}
a.f = f
a:f()
instead of
local a = {}
function a:f()
end
a:f()
I thought it only added the table as the first parameter during "using" and not during "writing".
Anonymous >30d ago #p25369 >>quote [AutoMod] action=keep R:9 E:8 N:7 C:9 | The post offers a solid, well-supported argument against the premise and provides a relevant link. The argument is sophisticated and directly engages the technical context.
>>25359
That's actually the "opposite" of the prototype OOP object model (classless objects) inplemened in languages like self, Io and original JavaScript
Tables are just flexible enough to be able to reimplement the "inheritance by delegation" model
https://bibliography.selflanguage.org/_static/organizing-programs.pdf
Anonymous >30d ago #p25370 >>quote [AutoMod] action=keep R:10 E:8 N:7 C:9 | The post directly addresses the context by making a strong, concise point about Lua's table behavior compared to other languages.
>>25369
That's just how Lua tables work already without any extra work doe.
Same with JavaScript objects
Anonymous >30d ago #p25371 >>quote [AutoMod] action=keep R:7 E:8 N:7 C:8 | The user provided a functional, albeit slightly verbose, demonstration of object-oriented concepts in Lua. The implementation is creative and directly addresses the thread context.
this is how i do classes btw desu not sure if matters thoughbeit
local function class()
local a = {}
a.type = "class"
return a
end
local function Animal()
local a = class()
a.type = "animal"
a.eat = function(food)
end
return a
end
local function Canine()
local a = Animal()
a.type = "canine"
a.bark = function()
print(a.type, "barks")
end
return a
end
local meow = function(s)
print(s.type, "meows")
end
local function Feline()
local a = Animal()
a.type = "feline"
a.meow = meow -- you must use here : but it will use less memory
return a
end
Anonymous >30d ago #p25372 >>quote [AutoMod] action=keep R:8 E:7 N:6 C:8 | The user provides a direct, albeit slightly contrarian, argument against Lua based on a specific, frustrating experience. The writing is clear and directly addresses the thread's topic.
>>25285
For a few weeks I ran the AwesomeWM window manager. It uses Lua instead of a configuration syntax. It was really annoying to work with. I remember needing to set a variable and it was ignored. Finally I set the variable to the value I wanted twenty times within the Lua script in order to get it to work.
So, yeah, I think Lua is a bad idea.
If you want a tiny language inside of your program, why not BASIC or Forth?
Anonymous >30d ago #p25373 >>quote [AutoMod] action=keep R:9 E:8 N:7 C:9 | The post provides a solid, technical expansion on the relationship between Lua tables and JavaScript objects. The reasoning is sound and well-supported by technical concepts.
>>25370
>That's just how Lua tables work already without any extra work doe.
Tables are more general than that, that's why you write a library to "restrict" to a specific protocol
To implement the Object, the Lobby and multiple inheritance you want to write down the object model to avoid repeating every time the same code for any object
> Same with JavaScript objects
That's not a coincidence, js is heavily inspired by Self.
Its VM was the first dynamically typed object-oriented VM to achieve performances almost on par of optimized C++ for many workloads, and many techniques that later became standard in modern language runtimes:
> Adaptive compilation
> Inline caches (building on earlier work in Smalltalk)
> Polymorphic Inline Caches (PICs)
> Type feedback
> Dynamic recompilation
Then Js later introduces classes as syntactic sugar but still with prototypes under the hood
The problem is that
- Self is "dead-ish" (not really dead but being live image-based env l don't see it making a comeback)
- Io is still developed but too niche and tarteg wasm by default
- js ecosystem is too web-centric
Lua is a nice modern compromise because it's almost like those languages although more general
Anonymous >30d ago #p25374 >>quote [AutoMod] action=keep R:9 E:8 N:7 C:9 | The user provides a clear, technical argument about the convenience of using Lua's metatables over manual table manipulation. The writing is direct and relevant to the thread context.
>>25361
yes, the object library basically does that
But I rather have to type
UDPconnectionTrait = Conncection:clone {
-- overwrite functions
}
UDPConnection = UDPConnectionTrait:clone {
transport_proto = "udp",
-- representations parameters
}
rather than setting every time the metatables by hand
Anonymous >30d ago #p25375 >>quote [AutoMod] action=keep R:8 E:7 N:6 C:9 | The user is engaging in a technical discussion about Lua's capabilities and table structures. The post is relevant to the thread context.
Anonymous >30d ago #p25376 >>quote [AutoMod] action=keep R:10 E:9 N:8 C:9 | The post is a direct, humorous response to the preceding technical discussion. It fits perfectly within the context of a lighthearted, yet technically focused thread.
>>25285
>array index starts from 1
HAHHAHAHAHHAHAHAH
Anonymous >30d ago #p25377 >>quote [AutoMod] action=keep R:10 E:9 N:8 C:9 | The post is a direct, relevant response to the thread context and engages with the previous comments effectively. It is well-written and contributes to the discussion.
>>25376
> Using a number from indians
Nice try Rajesh
Anonymous >30d ago #p25378 >>quote [AutoMod] action=keep R:10 E:10 N:9 C:9 | This is a direct, relevant, and provocative question that fits the context perfectly. It challenges the user to engage with the core topic of performance comparison.
>>25285
Ask yourself why lua torch lost to pytorch
Anonymous >30d ago #p25379 >>quote [AutoMod] action=queue R:2 E:1 N:1 C:3 | The post directly addresses the thread context but offers a very weak, unprovable claim. It lacks substance for a meaningful discussion.
>>25378
There is no correlation between Lua and machine learning
Anonymous >30d ago #p25380 >>quote [AutoMod] action=keep R:9 E:8 N:7 C:9 | The post offers a specific, technical critique of Lua syntax and provides a concrete example for improvement. It is highly relevant to the thread context.
>>25354
not looking forward for new incompatible syntax.
in particular, ternary operator reusing : is a terrible idea. consider:
value = myobj ? myobj:func() : otherfunc()
oops, now value is either myobj or func():otherfunc()
Anonymous >30d ago #p25381 >>quote [AutoMod] action=queue R:1 E:2 N:1 C:1 | The post is a very short, aggressive reaction to a technical discussion. It is low effort but fits the context of the thread.
>>25354
>const
HECK YES
time to mog jeetscript
Anonymous >30d ago #p25382 >>quote [AutoMod] action=keep R:10 E:10 N:9 C:9 | The post directly addresses the OP's premise with a concise counterpoint. It is highly relevant and well-supported.
>>25381
PUC Lua already has const doe
Anonymous >30d ago #p25383 >>quote [AutoMod] action=keep R:9 E:8 N:7 C:9 | The post is a direct, relevant response to a technical discussion about Lua syntax and ternary operators. It engages directly with the quoted context effectively.
>>25380
>Due to a syntactical ambiguity, expression b cannot directly contain a method call obj:method(). For this case, use parentheses: cond ? (obj:method()) : default
>That said, nope, ?: stays. I'll confess: I'm a heavy user. Addicted, even.
Anonymous >30d ago #p25384 >>quote [AutoMod] action=queue R:1 E:2 N:1 C:1 | The post is a very short, nonsensical attempt to respond to the thread. It adds nothing meaningful to the discussion.
>>25382
In the most retarded way possible
local why <const> = "just why";
< prev
1
2
3
4
5
6
...
12 next >
Reply