I’m asking this of the Xojo folks. Is this a bug (and is a feedback report needed) or is this normal behavior (2015r2.1 OSX)?
If created a new timer and have its super set to xojo.Core.Timer. Within the timer I created a Dictionary as a property. When I access it’s “dot” properties/methods it looks like the old Dictionary. If I change the super for the Dictionary to xojo.Core.Dictionary then the “dot” properties/methods are for the new Framework.
My expectation is that when I add the property and set the super to Dictionary that the “Using” for xojo.core should be automatic under the covers. If my timer is explicitly set to use the new framework then the dictionary created as part of the timer should automatically be from the new framework.
Is my expectation wrong?
No you are not wrong, but Autocomplete doesn’t understand the Using clause. In fact, it may even lead you to type code that won’t compile. Best option right now is to abandon the Using clause entirely and type explicit class names.
Using has a scope, and the “maximum” is a method. There is no Using for a whole class.
You can even write something like this:
Dim dict As New Dictionary() // create a "classic" dictionary
For i As Integer = 0 to 9
Dim newDict As New Dictionary() // create a "new framework" dictionary
dct.Value("abc") = "abc" // use the "new framework" dictionary
dct.Value("abc") = "abc" // use the "classic" dictionary
This is incorrect, you can add a Using element to a class. But your code is not correct either. The
dct.Value("abc") = "abc" (which I think is suppose to be
dict.Value) points to the “classic” dictionary because that is how it was declared. The Using clause inside does not change what type of object it is. However, if the line is suppose to be
newDict.Value("abc") = "abc" then you would be correct.
Eli, I do understand that Using has scope. What I felt was incorrect/weird is that when I create a timer from xojo.core.timer that when I add a dictionary property to that timer the dictionary defaults to being a “classic” dictionary rather than being a xojo.Core.Dictionary.
What I expected was:
timer [new framework ]
dictionary as property [new framework]
timer [new framework ]
dictionary as property [“classic” framework]
I hope that clarifies what I was trying to convey.
There is no magic behind the Xojo module. Just like if you declared MyModule.SubModule.SomeClass and created a subclass outside the module, its properties and declarations would not search inside the module first.
And therefore since there is no Using clause for classes you have to explicitly specify the framework in the IDE for a class. You enter Dictionary or Xojo.Core.Dictionary which is specific for this class, not also for its members. There is no Using clause used and none applicable.
Look at this valid Xojo source code:
Inherits Xojo.Core.Timer // This does not and cannot influence properties, method arguments,
// source code, etc. within MyTimer
If Inherits Xojo.Core.Timer would do what you want, there would be the need for a pre-processor amending the members and the code within the class. A compiler would never be able to compile something like what you want from the above source code.
What you would want is this but it does not exist in Xojo:
Using Xojo.Core // everything within MyTimer would now use the Xojo.Core framework where applicable
As I wrote: Using has a scope, and the “maximum” is a method. Outside of a method body there is no Using possible.
And as I wrote, this is incorrect. Select your class, choose “Add To” and select “Using.”
Wow, when was this introduced?
Same time as the Using clause I believe.
Just found the blog entry. God, I wish entries in this forum could be deleted. Or be marked with an “embarrassingly wrong” icon…
Being wrong is a fact of life, we’ve all done it. I believe it’s better the leave the history intact and grow from it, than to try to pretend it didn’t happen.
I didn’t catch that either. I gave it a try and I don’t know what I’m doing wrong but it doesn’t work for me as I would expect. I added the Using Clause to my class and specified xojo.Core. To test this, in the constructor I added Dim X As Dictionary. When I reference the “dot” methods/properties they are still the “classic” dictionary not the new framework dictionary.
For me, I think your earlier post saying to abandon Using and explicitly reference the full class name is the best way to go so that there is no confusion about which framework is being used.
I know I’m right
The Using clause, either in code or in declarations, works in the compiler. But not in autocomplete, so this makes your life very confusing.
Honestly, I’m not even sure the current autocomplete can be made to handle this. But I know Joe and Norm have had some good ideas that I can only hope get implemented.
FWIW - In all my uses of the new framework, I’ve never relied on the Using clause. It isn’t that much more difficult to type:
The auto-complete works pretty well. And you then know for sure what sort of object you have as you see it explicitly instead of depending on a using causing buried somewhere else.
And don’t assume that just because you have created an object in the new framework that every property created under it is part of the new framework…
[quote=182377:@Jon Ogden]FWIW - In all my uses of the new framework, I’ve never relied on the Using clause. It isn’t that much more difficult to type:
Inconvenient, less readable, and a major pain in the bu tt?
You think it’s less readable to use Xojo.Core.Timer vs. Timer?
If you change completely to the new framework it is superfluous and verbose to always prepend Xojo.Core.
@Jon: I like to write my code like English (using properly named variables etc).
Compare and contrast:
The auto-complete works pretty well. And you then know for sure what sort of object you have as you see it explicitly instead of depending on a using buried somewhere else.
The Xojo.Core.auto-complete works Xojo.Core.pretty well. And Xojo.Core.you then Xojo.Core.know for sure what sort of Xojo.Core.object you have as Xojo.Core.you see it explicitly instead of Xojo.Core.depending on a using buried Xojo.Core.somewhere else.
You really think the second isn’t less readable???
Oh come on now Markus, example is total BS and you know it. Nowhere have I ever run into a person who says “For I as integer equals zero to you-bound open parenthesis some array close parenthesis” because code and speech are not equivalent.