News for hackers. Stuff that matters.
Re:I've been designing a language since 2009 – friends and I... by levodelellis on Sunday August 14, 2022 @02:59PM (#32461878)
> However I don't like that they start with an underscore

Early on _[A-Z] meant reserved variable so that's why it's currently _On. Many keywords are a single word and common enough that it shouldn't bother anyone that it's reserved. However I'm not great coming up with a style guide. On empty is two words, I have no idea how it should be written and everyone seems to have their own style.

Do you have a suggestion for the _On keywords?

> Why not only one? The compiler should know what to do because of the mut, out keywords

You noticed the out keyword? It's not recommended we only use that to interface with C code. Returning multiple variables is much better IMO (I won't speak for everyone). Accumulator and dynamic arrays are common enough that I didn't want to force people to write mut each time. It's simply `:=`

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