COMMUNITY

Haxe Language Aesthetic Feature Request

Dear Haxe community,
I have a tiny feature request for Haxe. I hope I am posting in the correct location.
Can we have Haxe be written without { } and ; like python (indentation sensitive)?

class Main 

    static function main() 

        var word:String = "I ran, I ran so far away!"

        trace(word)

        var new_word:Array<String> = word.split("")

        for (i in 0...new_word.length) 

            if (new_word[i] == 'I') 

                new_word[i] = 'You'

        trace(new_word)

        var wurd:String = new_word.join("")

        trace(wurd)

Unfortunately this probably is not going to happen any time soon since this is to big of a change.

Thank you for your reply! :+1:
Just to clarify, I mean to have it as an option and obviously keep the original style.

Even if this would be considered, it’s not by any means a “tiny” feature. Implementation aside, you have to design the syntax so it doesn’t have to sacrifice language features, like everything-is-an-expression.

I suggested colons optional a long time ago after reading about it being optional in another language. The concept was down voted by most, maybe views have moved but I doubt it.

In some situations you can omit brackets when code is on a single line, I think this should work…

for (i in 0...new_word.length) if(new_word[i] == 'I') new_word[i] = 'You';

These types of changes your requesting don’t really add much to Haxe they can be considered syntatic sugar and mostly at odds with Nicolas vision since they can remove clarity in that spaces and returns are not considered enough, atleast as far as I understand, they would also as Dan points out be easy source of new bugs for little gain.

Often when approaching a different language we want to change it more to what we are used to, but really we need to embrace how it works currently and create stuff with it - only then do we start to really see where changes are most needed. These ones not so much importance, they may make it easier to code Haxe like Python but that only diverges the possible styles of haxe code increasing the cognative overhead to new users, definitely such changes would be at odds with current language consideration of easy adoption, while it seems easy to you less so for say a java or c# dev.

It maybe possible to get your IDE to hide colons and brackets fairly easily, this is likely the most feasible option for you to consider.

Perhaps the most likely-to-happen solution is a custom preprocessor that would take the desired style and convert it into proper Haxe syntax. In that case you can have whatever you want.

I like that preprocessor idea. Rust has something similar called Slag. I dont know the inner workings of it, but that’s what made me believe it would be a tiny feature to implement in the first place.
Haxe has a beautiful syntax anyway, but I’m just picky and personally prefer python style.