Merge: understand writable as an annotation
authorJean Privat <jean@pryen.org>
Tue, 22 Jul 2014 03:17:01 +0000 (23:17 -0400)
committerJean Privat <jean@pryen.org>
Tue, 22 Jul 2014 03:17:01 +0000 (23:17 -0400)
commit6f907facf0708d90a8f589370dc44cd5d7ce89a3
tree20d39c93d88b5e0a100f9e1b7f903eddabe37d12
parentea7c76ef0d12c87f880582767242a725eab43355
parent5f952929f2a23b70aad1f0e9b27091d77124a83c
Merge: understand writable as an annotation

~~~.rb
class Toto
   var x: Int writable = 5 # before
   var y: Int = 5 is writable # after
~~~

This should become the new way, so while an active migration is not needed yet, once this PR is merger, new code should use the new notation.

Bonus: writable accepts an optional agrument that is the name of the writer.
This allows the reserve the name `foo=` for high-level setters.

Eg.
~~~.rb
class Toto
   var x: Int is private writable(set_x) # generates `set_x` instead of `x=`
   fun x=(v: Int) do # `x=` is feee, so I can use it for a distinct method
      assert x >= 0
      set_x(v) # I use the generated `set_x` as a private internal setter
   end
end
~~~

Pull-Request: #601
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
src/modelize_property.nit