umka-lang icon indicating copy to clipboard operation
umka-lang copied to clipboard

Change qualified identifier syntax from `a.b` to `a::b`

Open vtereshkov opened this issue 1 year ago • 3 comments

The proposed syntax is less ambiguous, which will improve code readability.

Before:

a.b()  // A function `b` from module `a` or a method `b` of variable `a`?

After:

a::b()  // A function `b` from module `a`
a.b()   // A method `b` of variable `a` 

A realistic example with the proposed syntax:

if input::getMouseScroll().y != 0.0 {
    ed.processWheel(input::getMousePos(), input::getMouseScroll().y)
}

This change is extremely easy to implement in the Umka interpreter. However, it will break a lot of existing code.

vtereshkov avatar Jan 28 '24 23:01 vtereshkov

This would solve many of the problems with module naming I have, however I don't like ::, it looks a bit noisy in my opinion. If possible, I think a single : would suffice.

By the way - if this is possible to implement in a different branch to test on SaveScum - would be very cool!

ske2004 avatar Feb 03 '24 16:02 ske2004

@skejeton I see what you mean, but the single : already has too many roles. It may again impact code readability and even cause syntactic ambiguities, such as case a: b or a ? b : c.

vtereshkov avatar Feb 03 '24 17:02 vtereshkov

That's true. :: is pretty good then.

ske2004 avatar Feb 03 '24 21:02 ske2004