Top
Best
New

Posted by 90s_dev 7/1/2025

Pluto is a unique dialect of Lua with a focus on general-purpose programming(github.com)
77 points | 40 commentspage 2
actinium226 7/1/2025|
I've heard that Lua can be configured to avoid dynamic memory allocation, potentially allowing it to be used in real-time safety critical contexts. I'm not sure if anyone has used it that way, but I wonder if Pluto retains this?
HexDecOctBin 7/1/2025|
More specifically, Lua allows you to inject your own memory allocator function, so one can get Lua to use a real-time allocator like TLSF operating out of a fixed memory block in such contexts.
tzury 7/1/2025|
Well, this is a very poor design, one which makes me think what is the purpose of this project in the first place?

    for i = 1, 10 do -- Loop 1.
        for ii = 1, 5 do -- Loop 2.
            break 1 -- This will break from Loop 2.
            break 2 -- This will break from Loop 1.
        end
    end
https://pluto-lang.org/docs/New%20Features/Break%20Statement
lifthrasiir 7/1/2025||
I don't particularly dislike that design, but Lua already supports a goto target label `::label::` so I think the following syntax would work better:

    ::outer:: for i = 1, 10 do
        ::inner:: for ii = 1, 5 do
            break inner
            break outer
        end
    end
gitaarik 7/1/2025|||
Seems logical to me. 1 = break the current level, 2 = break 1 level up, 3 = break 2 levels up, etc.

If you would do it the other way around, and then if you would add another for loop around the others, the breaks will break. You wouldn't expect that if you're modifying this code without looking at the current breaks or knowing about the break behavior.

If you however move the break statements inside a new for loop, at the most inner level, it would seem obvious that you have to update the break numbers.

nextaccountic 7/1/2025||
Adding a label to each loop and breaking by label (like in Rust) feels better and more resistant to code changes
quietbritishjim 7/1/2025|||
I often wished for a multi-level break statement when I started programming. But it turns out that, most of the time, you're best served by moving that whole chunk into its own function and using "return" instead of "break outer". That amount of control flow complexity usually justifies moving into a separate function anyway.
philsnow 7/1/2025|||
What's poor about it, the numbers in the example? Think of them as inner/outer instead of "1" and "2". Without this kind of break statement, what do you do when you want to exit the outer loop, something like this probably:

  local stop = false
  for i = 1, 10 do         -- outer loop
    if stop then break end
    for j = 1, 5 do        -- inner loop
      break                -- to break from inner loop
      stop = true; break   -- to break from outer loop
    end
  end
So this new feature fits with the general theme of pluto being a very-sugared lua.
aa-jv 7/1/2025||
This is just poor language design.

The reason one might find this cumbersome or problematic, is in the case of very large numbers of lines of code - sure, your example is visible and somewhat readable (arguable) in its current form - but tell me you won't have issues when the loop is 80 or 100 lines of code, and you need to add another inner loop as part of the development process.

Are you now going to go through and be sure all your breaks are numbered properly? Are you really, though?

Better, imho, would have been to introduce labels and "break <label>", but even that is going to cause more headaches than its worth.

Ultimately, one shouldn't write such horrid code anyway.

philsnow 7/1/2025||
Ah, well said on all points and i couldn't agree more.
chirsz 7/1/2025|||
I guess it is inspired by De Bruijn index[1].

[^1]: https://en.wikipedia.org/wiki/De_Bruijn_index

raincole 7/1/2025|||
That's a Lua dialect so I don't know what you expect ;)
ModernMech 7/1/2025|||

  "Pluto aspires to be a version of Lua with a larger feature-set, that is all. Pluto is not a Lua-killer, an attempted successor, or any of that. Many people (rightly so) love Lua precisely because of the design philosophy. And fundamentally, Pluto is a major deviation from Lua's design philosophy. Some may prefer this, some may not."
sweetgiorni 7/1/2025||
That's... interesting.
tzot 7/1/2025||
If the numeric argument to break is what you find interesting, then this is exactly the same construct as the shell's break argument:

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V...