Samah

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 31 total)
  • Author
    Posts
  • in reply to: Less verbose lambda syntax #3752

    Samah
    Participant

    I’ll assume that’s a no, then.

    in reply to: Less verbose lambda syntax #3725

    Samah
    Participant

    isn’t that what Lambda() and End are for?

    Pretty much, but the majority of the Monkey-X/MX2 community have an aversion to braces.

    in reply to: Less verbose lambda syntax #3691

    Samah
    Participant

    How hard would it be to tell the parser to make newlines optional for single statement lambdas, then? That should be a simple enough change, and if the developer prefers to split it across multiple lines, that’s up to them.

    in reply to: Less verbose lambda syntax #3688

    Samah
    Participant

    TBH, I find this unreadable… If you want to return something, why not state it?

    The idea is less about the implicit return statement and more about keeping a simple lambda on a single line.
    With a return statement and no inferred types it’s still quite legible. It just makes it much cleaner if you want to pass a single expression as a parameter to a function.

    [/crayon]

    Maybe it’ll grow on me (it has a tiny bit) but right now I just don’t see the need for it.

    If I add flatmap/filter/reduce to the Stack class and provide an example banana project, you’ll see the power of mini-closures and why it makes code much easier to understand. I’ve already added it, I’ll make a PR at some point.

    in reply to: Less verbose lambda syntax #3680

    Samah
    Participant

    Sorry, I’m not quite clear on your response. Was that “accept the pull request” or “accept the existing syntax”?
    One of the more powerful uses of lambdas/closures is to represent a very simple piece of logic (even one expression) as a first-class type. If the lambda in question is as simple as a comparison or equation, I think the condensed one-line syntax is quite acceptable.
    If the lambda has a lot of logic to it (event handlers, etc.) then it makes sense to spread it across as many lines as you need, as per the current syntax.

    in reply to: Extern method generics #3622

    Samah
    Participant

    I’ll be honest here, I’m trying to add some lambda stuff to bbArray. Since there are no extensions/categories (yet), it’s going to have to be externed and a PR into the core std library.

    [/crayon]

    And so on.

    in reply to: Ted2: Experimental Plugin System #3456

    Samah
    Participant

    Imo plugins in Lua. Then you can re-use existing libraries. Actually, I might even write a plugin that will execute Lua in the editor.

    in reply to: Experimental module manager now online! #3430

    Samah
    Participant

    Thanks, I might have to look at hacking in some reflection myself.

    in reply to: Experimental module manager now online! #3386

    Samah
    Participant

    I uploaded mx2lua a while ago and and it hasn’t been reviewed yet. :'(

    in reply to: Lua #2472

    Samah
    Participant
    in reply to: Experimental module manager now online! #2471

    Samah
    Participant

    Lua module v0.1.0 uploaded. Still major WIP, but it’s usable.
    I’d love to see what people can do with the current build so that I know the best direction to take the project.
    Reeaalllyyy hoping for reflection soon so I can make the field and method bindings automatic and transparent to the developer.

    in reply to: Should "asset::" be plural? #2414

    Samah
    Participant

    Singular makes sense to me, as it’s an identifier to a single asset. Kinda like the “file://” URI prefix. I would recommend against allowing both singular and plural. Just pick one and stick with it.

    in reply to: Generator ? #2326

    Samah
    Participant

    Just wait until mx2lua is a bit more mature. Then you can go mental with the coroutines. 🙂

    in reply to: Lua #2271

    Samah
    Participant

    Worked a bit more on the class binding. At the moment you still need to know how to do some low level stuff, but I hope to make this cleaner in the future.

    I added a very simple Mojo demo, too. It has a placeholder for “script reloading”, but you’ll need to change it to DoFile and make sure the Lua file is in the right place. Whenever I test it from my build script, it tries to look in the root monkey2 directory rather than the current directory.

    I’d love to see some of your usage examples so that I know how to make it betterer! Note: Coroutines are much nicer for handling entity logic, rather than constantly calling DoString as in my example.

    in reply to: Lua #2081

    Samah
    Participant

    Fixed. Stupid git (not you).
    git rm --cached native/luadist

    I’m working on a simple Mojo demo project at the moment, hopefully with a “reload script” shortcut. At the moment you’re mostly limited to calling MX2 functions that you declare yourself, so it’s still WIP for usefulness. Coming along, though!

    Reloading scripts will need to use DoFile rather than DoString(LoadString), as I believe the assets get baked into the distribution.

    Note when using DoString/DoFile/PCall, make sure to wrap it with an if statement and grab the string value at the top of the stack. If there was an error somewhere in your script, that error message will be on the stack. You can also give custom error messages in your MX2 registered functions using state.Error/ lua_error. This will push the error message and raise an exception that’s caught by the Lua VM. Note that this call does a long jump and never returns.

Viewing 15 posts - 1 through 15 (of 31 total)