-
Jan 13th, 2022, 11:06 AM
#1
[RESOLVED] Creating subset Collection of objects
Basically, my question is ... when we add an item to a collection that's a Variant containing an object, are we:
1) Adding the object to the Collection's internal Variant? or...
2) Nesting our Variant with our object inside the Collection's internal Variant.
Hopefully, I'm just adding the object and not my Variant.
Here's the loop, with the middle line being the one I'm worried about:
Code:
Dim v As Variant
For Each v In cFile
If v.Text = "geometry" Then cGeom.Add v
Next
Specifically, I'm trying to make sure what that cGeom.Add v is doing.
Both cFile and cGeom are Collections (of tree nodes). cGeom should wind up being a sub-collection of cFile.
(Also, as an aside, I sure wish Collections had an AddSet property to make things more clear. However, I guess Add never looks at the default property, so it's sort of clear as it is.)
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 11:21 AM
#2
Re: Creating subset Collection of objects
To my knowledge you can add anything to a collection and they don't have to be of the same type for a single collection.
So you can add some primitives and then add a collection to the collection.
I never ever use variants so whether the variant is check by the Add method of the collection, I really don't know.
-
Jan 13th, 2022, 11:28 AM
#3
Re: Creating subset Collection of objects
Originally Posted by Arnoutdv
I never ever use variants so whether the variant is check by the Add method of the collection, I really don't know.
That's my whole point. Each item of a collection has two pieces (ignoring all the internal pointer), a Variant for the data, and a String for the key. And I'm not using the key so it's just a collection of variants.
And, to iterate a collection, I always use a Variant because that's what the collection item actually is.
And, in this case, all those collection variants are set with objects.
So, I just want to make sure that, when I'm moving my object reference from one collection to the other, am I nesting variants or am I just creating a new object reference?
p.s. I don't just willy-nilly use Variants either, but this is one case where you must.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 11:38 AM
#4
Re: Creating subset Collection of objects
I was having some other problems too, specifically passing a variant with a node, when the called procedure wanted an actual node. It wasn't letting me do that.
So, I just wrote the following to solve everything:
Code:
Public Function V2Node(v As Variant) As Node
' Moves a Variant with a Node into an actual Node.
Set V2Node = v
End Function
When adding to collections, and it's a variant with a node, I use that wrapper there as well. So, now there's no doubt about what I'm doing.
I'm still curious though, so I'll leave the thread open.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 11:42 AM
#5
Re: Creating subset Collection of objects
This should clear up any confusion:-
Code:
Private Sub Form_Load()
Dim myObj As Class1
Dim v As Variant
Set myObj = New Class1
Set v = myObj
Debug.Print "External variant address: " & CStr(VarPtr(v)) & ", Object address: " & CStr(ObjPtr(v))
FakeAdd v
End Sub
Private Sub FakeAdd(item As Variant)
Dim internalVar As Variant
Debug.Print "Variant argument address: " & CStr(VarPtr(item)) & ", Object address: " & CStr(ObjPtr(item))
Set internalVar = item
Debug.Print "Internal Variant address: " & CStr(VarPtr(internalVar)) & ", Object address: " & CStr(ObjPtr(internalVar))
Debug.Print TypeName(internalVar)
End Sub
Output:-
Code:
External variant address: 1701828, Object address: 128072688
Variant argument address: 1701828, Object address: 128072688
Internal Variant address: 1701632, Object address: 128072688
Class1
Basically what this shows is that a Variant inside a Variant is not a thing. When a Variant is passed to the Add function, it will simply copy the object address to a new Variant assuming the Collection utilizes Variants internally.
-
Jan 13th, 2022, 11:51 AM
#6
Re: Creating subset Collection of objects
Originally Posted by Elroy
It wasn't letting me do that.
Try changing signature to ByVal MyParam As MyClass so that you can pass Variant typed variables for this MyClass typed parameter too.
Originally Posted by Elroy
I'm still curious though, so I'll leave the thread open.
You are adding the object reference to the collection in both cases. It's not trivial to create a Variant which points to a Variant which contains an object reference.
cheers,
</wqw>
-
Jan 13th, 2022, 11:53 AM
#7
Re: Creating subset Collection of objects
Originally Posted by Elroy
I was having some other problems too, specifically passing a variant with a node, when the called procedure wanted an actual node. It wasn't letting me do that.
You were probably passing it by reference. For example:-
Code:
Private Sub Form_Load()
Dim c As Class1
Dim v As Variant
Set c = New Class1
Set v = c
ObjFunc v
End Sub
Private Sub ObjFunc(ByRef c As Class1)
Debug.Print c.Value
End Sub
The above would fail. However if you passed the object by value:-
Code:
Private Sub ObjFunc(ByVal c As Class1)
Debug.Print c.Value
End Sub
With the above change it would work.
EDIT:
wqweto beat me to it
-
Jan 13th, 2022, 11:54 AM
#8
Re: Creating subset Collection of objects
Originally Posted by Niya
Basically what this shows is that a Variant inside a Variant is not a thing. When a Variant is passed to the Add function, it will simply copy the object address to a new Variant assuming the Collection utilizes Variants internally.
Thanks Niya. That's what I was thinking/hoping.
Also, I just learned (and tested) something else I didn't know. You can use a specific class (not a Variant) to iterate a Collection so long as you're sure there's nothing else in the Collection. This fact solves a lot of problems for me:
For a Class1:
Code:
Option Explicit
Friend Property Get num() As Double
num = Rnd
End Property
To test what I said (in Form1):
Code:
Option Explicit
Private Sub Form_Load()
Dim c As New Collection
Dim num As Class1
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
'c.Add "asdf" ' If this is included, it will cause the iteration to error.
For Each num In c
Debug.Print num.num
Next
End Sub
p.s. No puns about eating cookies.
Last edited by Elroy; Jan 13th, 2022 at 12:05 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 12:02 PM
#9
Re: Creating subset Collection of objects
Originally Posted by wqweto
Try changing signature to ByVal MyParam As MyClass so that you can pass Variant typed variables for this MyClass typed parameter too.
Thanks for the tip. However, figuring out that I can use a variable declared with a specific class to iterate my collections is solving all of these problems.
This one really is resolved now.
Last edited by Elroy; Jan 13th, 2022 at 12:06 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 12:10 PM
#10
Re: Creating subset Collection of objects
Originally Posted by Elroy
Thanks for the tip. However, figuring out that I can use a variable declared with a specific class to iterate my collections is solving all of these problems.
Even if that were not possible, you could still iterate the Collection:-
Code:
Option Explicit
Private Sub Form_Load()
Dim c As New Collection
Dim num As Class1
Dim item As Variant
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
c.Add "asdf"
For Each item In c
If TypeOf item Is Class1 Then
Set num = item
Debug.Print num.num
'Handle non-Class1 type objects
ElseIf TypeName(item) = "String" Then
Debug.Print item
End If
Next
End Sub
You can even handle unexpected types in the Collection in whatever way you like.
-
Jan 13th, 2022, 12:20 PM
#11
Re: Creating subset Collection of objects
Originally Posted by Niya
Even if that were not possible, you could still iterate the Collection:-
You can even handle unexpected types in the Collection in whatever way you like.
Yeah, I understand ... that's basically what I was doing. But figuring out that I can iterate with a class (rather than a variant) just solves all kinds of things. It vastly simplifies things, and also makes calling other procedures within the iteration loop much easier (and clearer). And I love clarity.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 12:27 PM
#12
Re: [RESOLVED] Creating subset Collection of objects
Fair enough
-
Jan 13th, 2022, 12:28 PM
#13
Re: Creating subset Collection of objects
The collection class always accepts Variant variables. So if you pass a non-variant variable VB6 converts it to Variant and passes to the method. So if you pass already Variant variable VB6 doesn't perform this conversion.
-
Jan 13th, 2022, 01:46 PM
#14
Re: Creating subset Collection of objects
Originally Posted by The trick
The collection class always accepts Variant variables. So if you pass a non-variant variable VB6 converts it to Variant and passes to the method. So if you pass already Variant variable VB6 doesn't perform this conversion.
Ahhh, that's a nice way to explain it ... very clear and sensible.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 13th, 2022, 05:45 PM
#15
Re: Creating subset Collection of objects
Originally Posted by Elroy
Thanks Niya. That's what I was thinking/hoping.
Also, I just learned (and tested) something else I didn't know. You can use a specific class (not a Variant) to iterate a Collection so long as you're sure there's nothing else in the Collection. This fact solves a lot of problems for me:
For a Class1:
Code:
Option Explicit
Friend Property Get num() As Double
num = Rnd
End Property
To test what I said (in Form1):
Code:
Option Explicit
Private Sub Form_Load()
Dim c As New Collection
Dim num As Class1
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
Set num = New Class1: c.Add num
'c.Add "asdf" ' If this is included, it will cause the iteration to error.
For Each num In c
Debug.Print num.num
Next
End Sub
p.s. No puns about eating cookies.
This what always used without thinking about it.
I only ever have collections which have the same datatype.
Most often with a mother Class and child Classes
-
Jan 13th, 2022, 07:08 PM
#16
Re: Creating subset Collection of objects
Originally Posted by Arnoutdv
I only ever have collections which have the same datatype.
I use collections for all kinds of things, but yeah, the TypeName() of the items is typically all the same.
I just knew you couldn't iterate them with native types, for instance...
Code:
Option Explicit
Private Sub Form_Load()
Dim c As New Collection
c.Add "asdf"
c.Add "qwer"
c.Add "zxcv"
Dim s As String
For Each s In c
Debug.Print s
Next
End Sub
...won't work. I just never thought to try it with an object variable of a specific class (which does work, so long as that's all that's in the collection).
Never too late to learn something new.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 14th, 2022, 12:46 AM
#17
Re: Creating subset Collection of objects
Originally Posted by Elroy
...won't work. I just never thought to try it with an object variable of a specific class (which does work, so long as that's all that's in the collection).
This is a compiler shortcoming (pure lazyness). There is no reason As Object typed iter variable working ok but As String not to.
Probably TB will allow this as it already has to provision failure with type coercion on As Object iterators so allowing any type with IEnumVARIANT should not be too different/difficult.
cheers,
</wqw>
-
Jan 14th, 2022, 05:18 AM
#18
Re: Creating subset Collection of objects
Originally Posted by wqweto
This is a compiler shortcoming (pure lazyness).
Hmmm...I'm actually not sure it's laziness. I think MS backed themselves into a corner with certain design choices in VB6. This idea that primitives and objects are fundamentally different is what I believe is the problem here. Think about the following code:-
Code:
Dim v As Variant
If TypeOf v Is TextBox Then
Debug.Print "TextBox"
ElseIf TypeOf v Is Integer Then
Debug.Print "Integer"
End If
The above code is invalid because VB6's type system is not symmetrical and this has the potential for pure mischief. I don't know if you're aware but back when I first tested TwinBASIC, I ran into a huge problem with this when testing generics in TwinBASIC. Long story short, there was no way to write a generic class that caters to all types in TwinBASIC. Either you can cater to primitives like Strings and Integers or you could cater to Objects but not both. Microsoft promptly got rid of this problem when they created VB.Net. The above code actually works in VB.Net:-
Code:
Dim v As Object = 89I
If TypeOf v Is TextBox Then
Debug.Print("TextBox")
ElseIf TypeOf v Is Integer Then
Debug.Print("Integer")
End If
It should come as no surprise that you could also iterate over lists of any type in VB.Net.
Going back to my experience trying to make generics work with all types in TwinBASIC, I found myself trying all kinds of different hacks to get around the problem but failing in the end. It is entirely probably Microsoft knew they painted themselves into a corner and decided to just accept that limitation in the end. The asymmetrical nature of VB6's type system is one of it's biggest failings. I would also point out that most other OO languages do not treat Objects and primitives as fundamentally different. For example in C++, you can use something like sizeof against a class/structure just as you could an int or a char.
-
Jan 14th, 2022, 05:38 AM
#19
Re: Creating subset Collection of objects
Originally Posted by Niya
Hmmm...I'm actually not sure it's laziness.
Anything one can fix with just one line of additional UserCode -
would be equally easy to fix at compiler-level (basically).
The "User-Fix" for a String-Typed enumeration in a For Each loop would be:
Code:
For Each vStrItem In ColWithStrings
sStrItem = vStrItem 'it's just this coercion-call which the compiler would have to emit
...
And if the compiler-writer is at it, reducing the efforts of "explicit Pre-Dimming of Loop-Vars" at this occasion,
would be another, relatively easy to apply addition.
But Wayne is aware of that already, IIRC...
Olaf
-
Jan 14th, 2022, 06:18 AM
#20
Re: Creating subset Collection of objects
Originally Posted by Schmidt
Anything one can fix with just one line of additional UserCode -
would be equally easy to fix at compiler-level (basically).
Yes, I'm aware of this work around. But it's just a band aid. It doesn't address the real problem which is the type system. Going back to my generics problem in TwinBASIC, if I remembered correctly, I could have used Variants there to solve my issues as well. However, it just felt wrong. I can't really explain it but it feels wrong having to perform internal coercions like that is hidden from the users of the class, not to mention it completely defeats the purpose of having generics in the first place. The idea behind generics is not having to sap performance by performing unnecessary coercions. Microsoft probably felt a similar way about iterating over a collection using a non-Variant control variable. If I were in their shoes to be honest, I would have done the same thing. Let the programmers work around it. I would not have the compiler implement hidden coercions like that because when they start looking at it's performance, it's going to frustrate them that the compiler is doing voodoo that they can't control. It's better to let the programmer decide for themselves if they want sacrifice a bit of performance for flexibility. That's just my take on it.
Last edited by Niya; Jan 14th, 2022 at 06:27 AM.
-
Jan 14th, 2022, 07:00 AM
#21
Re: Creating subset Collection of objects
Originally Posted by Schmidt
Anything one can fix with just one line of additional UserCode -
would be equally easy to fix at compiler-level (basically).
The "User-Fix" for a String-Typed enumeration in a For Each loop would be:
Code:
For Each vStrItem In ColWithStrings
sStrItem = vStrItem 'it's just this coercion-call which the compiler would have to emit
...
And if the compiler-writer is at it, reducing the efforts of "explicit Pre-Dimming of Loop-Vars" at this occasion,
would be another, relatively easy to apply addition.
But Wayne is aware of that already, IIRC...
Olaf
Yes, the funny thing is this already happens for reference iterators (As Object or other) but somehow stumbled codegen for non-reference types.
Originally Posted by Niya
The above code actually works in VB.Net:-
. . . but the price to pay is ginormous performance penalty on *boxing* primitive types.
Yes, VB6 does not do boxing and we are grateful this was not conceived as an idea by MS until later Java implemented something similar.
cheers,
</wqw>
Last edited by wqweto; Jan 14th, 2022 at 07:03 AM.
-
Jan 14th, 2022, 08:28 AM
#22
Re: Creating subset Collection of objects
Originally Posted by wqweto
. . . but the price to pay is ginormous performance penalty on *boxing* primitive types.
I'll have to look into it but I don't think you pay any boxing penalty for using the Is operator on a primitive type in VB.Net. My point is that fundamentally the type system in .Net doesn't treat primitives and classes as different as it does in VB6. Boxing/unboxing is a consequence of this design, that is true, but it is never forced on you. In my opinion it is a very small price to pay to avoid having to write code like this:-
Code:
Public Property Get Item(ByVal Index As Long) As Variant
'Use zero based indexing because 1 based indexing
'is ****in retarded
Assign g_items.Item(Index + 1), Item
End Property
Private Sub Assign(ByVal value As Variant, ByRef var As Variant)
'This is necessary to handle both objects and non-objects
'because of the massive retardedness that is the Set statement.
If IsObject(value) Then
Set var = value
Else
var = value
End If
End Sub
The above is an extract from the Pratt Parser demo I uploaded to the CodeBank last year. It's part of a Collection backed ArrayList class I wrote for easier handling of array-like data. Highlighted in red are the things I wish I didn't have to do.
EDIT:
For contrast, this is how this would look in VB.Net:-
Code:
Public ReadOnly Property Item(ByVal Index As Integer) As Object
Get
Return g_items.Item(Index)
End Get
End Property
The above incurs a boxing penalty for primitive types but I'd rather pay that price for this simplicity.
However, we don't have to pay that boxing penalty if we don't want to. We can use generics:-
Code:
Public Class ArrayListClass(Of T)
Private g_items As T()
Public ReadOnly Property Item(ByVal Index As Integer) As T
Get
Return g_items(Index)
End Get
End Property
End Class
T can be anything. It can be a primitive or it can be a class, structure or even a delegate. There is no need to be concerned with this because all types are treated equally at a fundamental level.
Last edited by Niya; Jan 14th, 2022 at 08:43 AM.
-
Jan 14th, 2022, 08:59 AM
#23
Re: Creating subset Collection of objects
Originally Posted by Niya
My point is that fundamentally the type system in .Net doesn't treat primitives and classes as different as it does in VB6.
That would be hard to believe. Treating everything homogenously as a reference type has its drawbacks in performance.
I thought they made some progress in reverse directions with value types in recent versions following performance demands from users.
In VB6 you can invoke Type Of operator on a value type only by wrapping it in a Variant and ultimately getting a run-time error. Another option is to use VarType and TypeName both with their own warts.
.Net type system is so much more modern and versatile that there is no point comparing it.
Btw, TB has Return statement and it sort of emulates your Assign impl.
cheers,
</wqw>
-
Jan 14th, 2022, 09:16 AM
#24
Re: [RESOLVED] Creating subset Collection of objects
Well, if we really wanted to, it's easy enough to "fix" in VB6 code.
For a Class1:
Code:
Option Explicit
Public str As String
For a Form1 test:
Code:
Option Explicit
Private Sub Form_Load()
Dim coll As New Collection
Dim sObj As Class1
Set sObj = New Class1: sObj.str = "asdf": coll.Add sObj
Set sObj = New Class1: sObj.str = "qwer": coll.Add sObj
Set sObj = New Class1: sObj.str = "zxcv": coll.Add sObj
For Each sObj In coll
Debug.Print sObj.str
Next
End Sub
Now that I know I can iterate with an object variable, this becomes easy.
EDIT1: In fact, it becomes even a bit easier if we set the class's default property:
Then we can just do something like the following in our Form1:
Code:
Option Explicit
Private Sub Form_Load()
Dim coll As New Collection
Dim s As Class1
Set s = New Class1: s = "asdf": coll.Add s
Set s = New Class1: s = "qwer": coll.Add s
Set s = New Class1: s = "zxcv": coll.Add s
For Each s In coll
Debug.Print s
Next
End Sub
Last edited by Elroy; Jan 14th, 2022 at 09:46 AM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 14th, 2022, 09:40 AM
#25
Re: [RESOLVED] Creating subset Collection of objects
You can even mark str as default property and use sObj = "asdf" and Debug.Print sObj straight.
cheers,
</wqw>
-
Jan 14th, 2022, 09:58 AM
#26
Re: [RESOLVED] Creating subset Collection of objects
Originally Posted by wqweto
You can even mark str as default property and use sObj = "asdf" and Debug.Print sObj straight.
cheers,
</wqw>
haha, beat'cha to it.
EDIT: Actually, I'm not sure I did. My modify time is 8:46 and your post time is 8:40. I must have hung onto editing my post too long.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 14th, 2022, 10:00 AM
#27
Re: Creating subset Collection of objects
Originally Posted by wqweto
That would be hard to believe. Treating everything homogenously as a reference type has its drawbacks in performance.
Hmmm..I'm talking about it at a more fundamental level. All types, whether they are value types or reference types are descended from the Object type in .Net. This means at the most basic level all types are the essentially made up of the same stuff. Now they can be different. Some types are value types, some are reference types, this is true and you can't treat those the same. However when it comes to very basic operations like comparing types, this is where the foundation of the type system is important.
Going back to an earlier example. This:-
Code:
Dim v As Object = 89I
If TypeOf v Is TextBox Then
Debug.Print("TextBox")
ElseIf TypeOf v Is Integer Then
Debug.Print("Integer")
End If
Is the same as doing this:-
Code:
Dim v As Object = New Integer
If v.GetType = GetType(TextBox) Then
Debug.Print("TextBox")
ElseIf v.GetType = GetType(Integer) Then
Debug.Print("Integer")
End If
The above shows that beyond the nuanced differences between different types like objects and primitives, they are all built on the exact same foundation, one of which is having a singleton Type object associated with it. This is what I think the VB6 type system is missing. I get the feeling that there is a big disconnect between primitives, objects and UDTs in VB6 and it's a source of many problems that don't exist in a more unified type system.
-
Jan 14th, 2022, 10:05 AM
#28
Re: [RESOLVED] Creating subset Collection of objects
In my somewhat repeated dabblings in .NET, I've also noticed that ... it prefers to have everything as an object.
To my way of thinking, that's another example of how .NET bloats everything. If I just want a Single or a Long, all I want is four bytes for storage, and whatever memory pointers are necessary to find them again, nothing else.
And, as illustrated above, if we want them as an object, it's easy enough to wrap them.
EDIT: Oh dear , I've fallen into the trap.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 14th, 2022, 11:12 AM
#29
Re: [RESOLVED] Creating subset Collection of objects
Originally Posted by Elroy
In my somewhat repeated dabblings in .NET, I've also noticed that ... it prefers to have everything as an object.
To my way of thinking, that's another example of how .NET bloats everything. If I just want a Single or a Long, all I want is four bytes for storage, and whatever memory pointers are necessary to find them again, nothing else.
And, as illustrated above, if we want them as an object, it's easy enough to wrap them.
EDIT: Oh dear , I've fallen into the trap.
Not that I want to turn this into another VB6/VB.Net debate or anything but I feel compelled to point out that this is a huge misconception. When you look at the disassembly that represents the machine code produced by the compiler, you don't actually see any bloat. For example if you did this:-
Code:
Dim a As Integer = 2
Dim b As Integer = 3
Dim c As Integer = a + b
The actual assembly for the addition looks like this:-
Code:
00DB1FED mov dword ptr [ebp-44h],2
00DB1FF4 mov dword ptr [ebp-48h],3
00DB1FFB mov eax,dword ptr [ebp-44h]
00DB1FFE add eax,dword ptr [ebp-48h]
If someone told you that was generated by a C compiler, there is nothing in there to prove otherwise.
What most people don't realize is that a lot of what you call "bloat" is just an illusion meant to facilitate you in expressing your ideas in code more easily. A lot of it is stripped out of the actual compiled code that executes on your processor.
Just to drive home the point about this being an illusion. Lets see how the illusion actually works. Look at this code:-
Code:
Dim i As Integer = 9
Dim b As String
b = i.ToString
The above code would lead one to suspect that Integers in VB.Net are these heavy bloated objects. Right? I mean you're calling a ToString method so it has to be that every Integer in memory is this huge object with methods and properties right? No. It's an illusion. If you look at the disassembly, you will see this:-
Code:
Dim i As Integer = 9
02F81FE3 mov dword ptr [ebp-44h],9
Dim b As String
b = i.ToString
02F81FEA lea ecx,[ebp-44h]
02F81FED call System.Int32.ToString() (7047E1D0h)
02F81FF2 mov dword ptr [ebp-4Ch],eax
02F81FF5 mov eax,dword ptr [ebp-4Ch]
02F81FF8 mov dword ptr [ebp-48h],eax
As the above shows, highlighted in red, the Integer is just a DWORD value in memory. Nothing more. Highlighted in green is how ToString is actually implemented. It puts the pointer to the integer value in the ECX register and makes a call to some piece of code at address 7047E1D0h which is what performs the conversions. This is typical of what any compiler would produce for any normal function call in any language whether it's VB6, C or VB.Net. Whoever led you to believe otherwise has lied to you.
-
Jan 14th, 2022, 12:08 PM
#30
Re: [RESOLVED] Creating subset Collection of objects
Ok, I'm done. I could go on, but it's really not where I want my head to be. So, for anyone who wants to continue debating difference (advantages, disadvantages, bloat, etc) between VB6 and .NET, let's take it here, because, no matter what's said, I'm not taking this project to .NET.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 14th, 2022, 12:13 PM
#31
Re: [RESOLVED] Creating subset Collection of objects
I'm not trying to convert you Elroy. I'm just pointing out some facts. Nothing more.
-
Jan 14th, 2022, 02:09 PM
#32
Re: [RESOLVED] Creating subset Collection of objects
Niya, your IMs appear to be full again. I was going to thank you for your last IM, but I couldn't send it. So, thank you.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Jan 14th, 2022, 02:34 PM
#33
Re: [RESOLVED] Creating subset Collection of objects
Ah yea. I probably need to clear out some old messages from years ago once more.
-
Jan 14th, 2022, 02:59 PM
#34
Re: [RESOLVED] Creating subset Collection of objects
Aite. I cleared out a bunch of stuff from my Inbox and Outbox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|