Quote:Original post by jpetrie
...what is the scope of the executing code, for example? Can it access 'this'
Eh, not sure how'd it be implemented, but scope would be the same as the injector. Which is to say scrollbar would be the scrollbar in the class using the when keyword, not the Scrollbar class. I'm not sure, exactly, what would be done in cases where the variable in question no longer exists. Class-wise, the when code could just be uninjected when the class is disposed/GC/whatever. But for variables who have a scope limited to a function or the inside of an if-statement, I'm not sure. >_> Perhaps a compile-time check to make sure the variable in use has a scope equivalent to that of the class?
Quote:Original post by jpetrie
When exactly does it run for complex setters?
Tacked on at the end, in order of injection.
public int SetMe{ set { me=value; /*when usage 1*/ /*when usage 2*/ /*...*/ /*when usage n*/ } }
Also, although C# like syntax is in use, this isn't inteded to mean I'm suggesting when for the C# language, but rather overall.
Quote:Original post by Heptagonal
Edit: jpetrie posted while I was posting.
Since you used MessageBox.Show()
in your example, I presume you are using C#. So why don't you just put it into the "setter" of the Value property?
I'm presuming jpetrie's post explained for you that the properties' code isn't accessible? :/ I need to explain things better...
Quote:Original post by Heptagonal
Oh, and I also don't like the use of is. It serves no purpose, and when you have a variable with a name in plural form, it becomes odd.
The purpose it serves here is so the when keyword would know which property the condition/code is to be applied to.
when(scrollbar.Value>scrollbar.Maximum) could be used, yes, without the need for the is keyword, but then there might be confusion over something like when(scrollbar.Maximum>scrollbar.Value), where the condition/code would be injected into the scrollbar.Maximum property, since it is the first property 'found'.
Using the is keyword clears up which property the condition/code is to be applied to.
Bloody double-posting frown-upons.... ;-;