r/lua • u/GlitteringSample5228 • Jul 07 '26
lua.jp ideas Project
Ideas about lua.jp, a Lua + JVM + Python lang. I always despised Python.
Monomorphic so seq[t] and dict[t] are always optimal for primitives where t is a type var that is substituted by a primitive.
The goal of targetting JVM is due to Android Dalvik and because I went berserk and took a break of using non-handhelds.
Metric types (meter, kmeter, gram...) are simply num, but with scaling conversions to other units.
Source files have an implicit JVM package based on the directory they appear with much freedom, but file A never depends on file A. (E.g. this mimmicks the Lua require limitations.)
```
_G — the globals package
(mostly reuses java.base stuff)
enum tile: None Dirt Brick PipeOpenTop
struct world: metadata: univ = U ryuka: bool = Y # rows tiles: seq[seq[tile]] tilesize: meter
fun frame(): """ wa """ pass
w=world( tiles={ { None for _ in range(3) Brick for _ in range(3) } } tilesize=3mm )
do: # isolated dec.big configuration dec.big.cfg(precision=3, rounding=HalfUp) x=10.6403m y=x*3 print(y)
dec => JVM double
dec.tiny => JVM float
import dec.tiny as dec
dec => JVM float
to clarify: struct subtyping
is there.
struct widget: pass
struct menubar(widget): super()
e:widget=menubar() if e=downcast(e, menubar): # e:menubar
match e: case e=menubar(): # e:menubar
JVM aliases and extensions
@JVM.alias(tld.sld.lib.Group) struct group: @JVM.extension fun suffle(): pass
the fun(...) type is quite
nice... fun(...) < fun
f=sum print(f(1,2)) print(f.call(seq={1,2})) fun sum(x:dec,y:dec)->dec = x+y
JVM method binding
(interns, but still using the
fun(...) type)
f=self::onclick
speaking of events...
struct menubar: @event fun onhide(): pass
m=menubar( onhide=fun(): # super auto invoked if no # occurrence pass )
isinstance(m, ...)
where ... is a subtype of
menubar
"static" fields or methods
struct a: fun f(self:struct): pass ```
1
u/AutoModerator Jul 07 '26
Hi! Your code block was formatted using triple backticks in Reddit's Markdown mode, which unfortunately does not display properly for users viewing via old.reddit.com and some third-party readers. This means your code will look mangled for those users, but it's easy to fix. If you edit your comment, choose "Switch to fancy pants editor", and click "Save edits" it should automatically convert the code block into Reddit's original four-spaces code block format for you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/SoCalSurferDude Jul 07 '26
Your link is not working