GaijinEntertainment / daScript

daslang - high-performance statically strong typed scripting language
https://daslang.io
BSD 3-Clause "New" or "Revised" License
909 stars 102 forks source link

property operators #1288

Closed borisbat closed 1 month ago

borisbat commented 1 month ago

assignment operators like += and such now work on properties

struct Foo
    n : string
    def operator . name
        return n
    def operator . name := ( v : string )
        n = v

[export]
def main
    var f : Foo
    f.name = "Hello, World!"
    print( "f = {f}\n" )
    f.name += " (again)" // NOTE += on property
    print( "f = {f}\n" )