Enhanced "Const"
Monkey Forums/Monkey Programming/Enhanced "Const"
| ||
Mark, could we get some more usage out of the Const keyword? Essentially, I'd like it to do the following things: Class Foo ... Const ' makes the class final so you can't extend it Method Foo ... Const ' makes the method final so you can't override it Obviously some keywords would be exclusive-or. It doesn't make sense to have both Abstract and Const on a method or class declaration. :) |
| ||
Someone's coming from a final Java background here... |
| ||
Can't you use "Final" or am I missing something? I'd be nice (but not necessary) if we can make a Function() ... Const for C macro-like functions. |
| ||
Someone's coming from a final Java background here... Gasp... how ever did you guess? ;) |
| ||
What is the use for this? |
| ||
For library developers. Less ways to break means less bug reports. :) |
| ||
Hi, I'd be in favor of using 'Final' here myself. I like that Const saves a new keyword, but I think it's a little confusing/misleading. Any objections to 'Final'? |
| ||
Final is ok for me, I would raise an objection to Const |
| ||
That's fine with me. :) I only suggested "Const" because it's an existing keyword and it does what "final" does in Java (for fields/variables). |
| ||
I would have to agree that whilst it saves a keyword, it is a little misleading, +1 for Final. Nice suggestion Samah :) |
| ||
Of course you should still be able to declare extended classes and overridden methods as Final.Class Foo End Class Bar Extends Foo Final ' OK, Foo is not final, but Bar is End Class Test Extends Bar ' Fail, can't extend Bar End and... Class Foo Method SomeMethod() End End Class Bar Extends Foo Method SomeMethod() Final ' overrides SomeMethod in Foo and makes it final End End Class Test Extends Bar Method SomeMethod() ' Fail, SomeMethod in Bar is final (even though in Foo it's not) End End |