News for hackers. Stuff that matters.
Re:I've been designing a language since 2009 – friends and I... by pmontra on Monday August 15, 2022 @01:48AM (#32466271)
> Do you have a suggestion for the _On keywords?

Let's suppose that in the future you want to add an argument to the break keyword to signal why the loop returned early. I use a string (btw, does the language have symbols / atoms?)

  break "found" 
  break "eof" 
  break "invalid input" 
Then you could have

  on "found" 
  on "eof" 
  on "invalid input" 
with only one keyword. And

  on "complete" 
  on "empty" 
> Returning multiple variables is much better IMO

I agree but declaring a name for what you return is nice because it explains the purpose of the returned values. They could go outside the ()s.

  stat(file) out length, created, modified
Re:I've been designing a language since 2009 – friends and I... by levodelellis on Tuesday August 16, 2022 @05:17PM (#32489070)
I'm thinking more about your suggestion but off the top of my head I don't know why one would want a break reason. If one comes up anytime soon I'll 100% remember this post

> I agree but declaring a name for what you return is nice because it explains the purpose of the returned values. They could go outside the ()s.

So you're not suggesting an 'out' keyword your saying names on return values? I like the idea but in practice I'm not sure if any IDE would show you the names? I think many do show comments if you place them the line before so that could be an alternative solution

One reason I don't like out params is because it conflicts with the design of the language. The language prefers you to assign variables and people will want to modify their variables (or arrays and struct members) with the out param and having something be declare OR assign causes problems because its too easy to make a typo and not find it for many many minutes. Writing the type then using out goes against the flow of the language which is why I prefer returning multiple values.

But I don't know all the use cases and everyones preference so there very well be a good reason you'd want an out parameter