From: Jean Privat Date: Fri, 10 Apr 2015 15:19:40 +0000 (+0700) Subject: Merge: Sys is top X-Git-Tag: v0.7.4~31 X-Git-Url: http://nitlanguage.org Merge: Sys is top And when I say *top* I mean *great*. But I also mean *top* in fact. The idea is to move the top-level methods (those defined outside classes) from Object to Sys. While this is a cosmetic move, it has a lot of benefits: * top-level methods get a real meaningful receiver: the current system. It is meaningful both on the declaration side and the call side. * no more need to distinguish the concept of top-level methods with their rules and semantic, so this simplify the language with one less thing (almost, see bellow) * self is now usable in top-level methods, not that useful now because it is `sys`, a singleton, but this allow some kind of inheritance if you add super-classes to Sys. * no more name conflicts between a standard class method and a top-level method * no more useless slots in table of classes for crazy methods defined in Object and never redefined * close #461 and close #1081 by making them irrelevant * Let us see a bright future where the singleton Sys become a multiton and allow specific isolation of computation. Specific Sys will then be active objects (threads, computation node, actors, whatever) isolated with their own specific cloud of objects and efficient lock-less concurrency, dedicated memory model (realtime?), and why not transparent distribution There is still two drawbacks * what is the status of `sys` that represent the current `Sys`? I hard-coded it to stay a method in Object. One way to solve the probem is to make it a keyword (like `self`) * when doing `foo(x)`, first this tries `self.foo(x)` then `sys.foo(x)` thus this is some additional rule of the language. Pull-Request: #1249 Reviewed-by: Alexis Laferrière Reviewed-by: Alexandre Terrasa Reviewed-by: Lucas Bajolet --- 2ef74df2c2b1eb3e370b1dc6a59307fae07e1ee0 diff --cc tests/sav/nitlight_args1.res index 8b7dbb3,c5a6adb..570c986 --- a/tests/sav/nitlight_args1.res +++ b/tests/sav/nitlight_args1.res @@@ -26,42 -26,42 +26,42 @@@ fun output is intern end -class A - init do 5.output - fun run do 6.output +class A + init do 5.output + fun run do 6.output end -class B - var val: Int - init(v: Int) +class B + var val: Int + init(v: Int) do - 7.output - self.val = v + 7.output + self.val = v end - fun run do val.output + fun run do val.output end -class C - var val1: Int - var val2: Int = 10 +class C + var val1: Int + var val2: Int = 10 end - fun foo do 2.output - fun bar(i: Int) do i.output - fun baz: Int do return 4 -fun foo do 2.output -fun bar(i: Int) do i.output -fun baz: Int do return 4 ++fun foo do 2.output ++fun bar(i: Int) do i.output ++fun baz: Int do return 4 -1.output -foo -bar(3) -baz.output +1.output +foo +bar(3) +baz.output -var a = new A -a.run +var a = new A +a.run -var b = new B(8) -b.run +var b = new B(8) +b.run -var c = new C(9) -c.val1.output -c.val2.output +var c = new C(9) +c.val1.output +c.val2.output