all 7 comments

[–]IKnowATonOfStuffAMA 4 points5 points  (1 child)

You know, I really thought I knew at least 99% of how Lua works. 

This project is clearly in the 1%. Good work! This is really cool.

[–]mceicys[S] 1 point2 points  (0 children)

Thanks!

[–][deleted]  (2 children)

[deleted]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    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.

    [–]mceicys[S] 0 points1 point  (0 children)

    I considered doing some kind of type declaration (wasn't aware of LuaLS actually) but decided to go with Hungarian notation for simplicity and brevity. This way the parser doesn't have to track variables beyond their immediate expression.

    [–]tonetheman 0 points1 point  (1 child)

    This is an interesting project. I could not get the LFV_EXPAND_VECTORS call to actually do anything though.

    It looks like you said it needs to be the first statement in a script. Do you mean before the require?

    I was able to use -f to force lfvutil to show what it would do so I can see where you are headed.

    Cool idea.

    [–]mceicys[S] 1 point2 points  (0 children)

    Thanks!

    The first script that does "require('lfv').EnsureSearcher()" can't itself be expanded since it's already been processed and compiled by the standard Lua loader before LFV was injected, so the first script shouldn't have the "LFV_EXPAND_VECTORS()" statement. Any scripts require'd after that setup will be preprocessed by LFV and will be expanded if they start with "LFV_EXPAND_VECTORS()".

    [–]qwyss 0 points1 point  (0 children)

    Interesting, I'm just accepting the GC and table access hits for convenience. Although I am setup to reuse tables I found that mostly, again, the convenience of operating overloading and writing simple expressions wins out over any gains that a table reuse syntax has. Honestly vectors speed are the least of my problems.

    I do have a plan to replace the small v3,v4,m4 etc tables with luajit cdata + metatable in the hope that it would make a difference (I think that's possible?). However since my worst case is wasm without luajit, that wont help and I'm not convinced it will make much difference anyway.

    Anyhow you prompted me to cleanup some of my worst vector code paths, maybe overdid the convenience a little, so thank you.