# Auto vs. Variant, when to use Auto?

**URL:** <https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169>\
**Category:** General\
**Created:** [May 11, 2015, 3:50am UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169 "2015-05-11T03:50:54Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Jeremy\_Cowgar](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremy_cowgar/32/4590_2.png) [@Jeremy\_Cowgar](https://forum.xojo.com/u/Jeremy_Cowgar)\
**Post date:** [May 12, 2015, 2:39pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/41 "2015-05-12T14:39:57Z")

</div>

@Norman Palardy, I am all for Auto and no automatic type conversion. I never liked that about Variant, it’s dangerous. I am a big strict typing guy. I am all for less memory. I am not for Variant. What I am for is quicker type determination. In most cases (that I use Variant for), I am simply interested in, what intrinsic type is it. Integer, Double, Object, etc… If it is an Object, then I will use other means to determine it’s type information, one of which is Introspection, another which is IsA.

Auto’s purpose is to store a variable of an unknown type. If I know what type the variable is, then I would use a real type when creating the variable. Therefore, if Auto is to be faster in real use, (i.e. using to store a value of an unknown type) then Auto has to have a fast type determination function. We are not asking for type conversion, but type determination.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [May 12, 2015, 2:41pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/42 "2015-05-12T14:41:01Z")

</div>

And again, nobody is arguing that you shouldn’t be allowed to use Introspection if that’s the level of detail that you need, only that it’s not as fast as the Variant.Type property in cases where that’s _all_ you need.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 2:45pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/43 "2015-05-12T14:45:27Z")

</div>

[quote=186621:@Kem Tekinay]  
Is revealing the type tied to these conversions somehow?[/quote]  
A “type” field has other implications

Additions / changes to auto will happen slowly & carefully so we don’t end up with the same set of variant issues

---

<div class="post-metadata">

**Author:** ![Jeremy\_Cowgar](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremy_cowgar/32/4590_2.png) [@Jeremy\_Cowgar](https://forum.xojo.com/u/Jeremy_Cowgar)\
**Post date:** [May 12, 2015, 2:47pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/44 "2015-05-12T14:47:09Z")

</div>

> [@186625:@Norman Palardy](#):
>
> Additions / changes to auto will happen slowly & carefully so we don’t end up with the same set of variant issues

So Auto changes are coming then? Presumably dealing with fast type determination? If so, that would probably end this discussion.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 2:50pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/45 "2015-05-12T14:50:18Z")

</div>

> [@186626:@Jeremy Cowgar](#):
>
> So Auto changes are coming then? Presumably dealing with fast type determination? If so, that would probably end this discussion.

I said no such thing  
What I did say was “Additions / changes to auto will happen slowly & carefully”  
And that includes making NO changes if that seems the right thing to do

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [May 12, 2015, 2:50pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/46 "2015-05-12T14:50:52Z")

</div>

Bah.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 2:52pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/47 "2015-05-12T14:52:30Z")

</div>

wheres that ignore button again ? 😛

---

<div class="post-metadata">

**Author:** ![Jeremy\_Cowgar](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremy_cowgar/32/4590_2.png) [@Jeremy\_Cowgar](https://forum.xojo.com/u/Jeremy_Cowgar)\
**Post date:** [May 12, 2015, 2:56pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/48 "2015-05-12T14:56:54Z")

</div>

I’m kind of curious how Auto is being used in the IDE without causing slow downs? Maybe a good example of how we are suppose to use Auto without introducing performance problems would solve this discussion as well.

---

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [May 12, 2015, 3:05pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/49 "2015-05-12T15:05:10Z")

</div>

I’d be willing to bet the IDE is using very little of the new framework.

---

<div class="post-metadata">

**Author:** ![Jeremy\_Cowgar](https://forum.xojo.com/user_avatar/forum.xojo.com/jeremy_cowgar/32/4590_2.png) [@Jeremy\_Cowgar](https://forum.xojo.com/u/Jeremy_Cowgar)\
**Post date:** [May 12, 2015, 3:14pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/50 "2015-05-12T15:14:03Z")

</div>

> [@186626:@Jeremy Cowgar](#):
>
> So Auto changes are coming then? Presumably dealing with fast type determination? If so, that would probably end this discussion.

I should say faster, easier and safer type determination. That’s what I’m hoping for. Right now Auto lacks in all three of those areas compared Variant. Again, not type conversion… I do not like that at all, it’s evil :-). Type determination though is our friend.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 3:21pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/51 "2015-05-12T15:21:16Z")

</div>

Personally I’d start with “correct type determination” and then worry about getting it faster, easier and safer

---

<div class="post-metadata">

**Author:** ![Joe\_Ranieri](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/43a26b/32.png) [@Joe\_Ranieri](https://forum.xojo.com/u/Joe_Ranieri)\
**Post date:** [May 12, 2015, 3:24pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/52 "2015-05-12T15:24:40Z")

</div>

> [@186640:@Jeremy Cowgar](#):
>
> I should say faster, easier and safer type determination. That’s what I’m hoping for. Right now Auto lacks in all three of those areas compared Variant. Again, not type conversion… I do not like that at all, it’s evil :-). Type determination though is our friend.

Auto uses less memory to store values, preserves type information much better than Variant, and lacks all of Variant’s implicit conversions. What it’s missing is a way to efficiently compare the value’s type to a predetermined type (and do so without using text literals).

I suspect what will end up happening is something like this:

`Select Case Xojo.Introspection.GetType(var)
Case GetTypeInfo(String)
  // Do something
Case GetTypeInfo(Integer)
  // Do something
Case GetTypeInfo(Double)
  // Do something
End Select`

---

<div class="post-metadata">

**Author:** ![scott\_boss](https://forum.xojo.com/letter_avatar_proxy/v4/letter/s/c5a1d2/32.png) [@scott\_boss](https://forum.xojo.com/u/scott_boss)\
**Post date:** [May 12, 2015, 3:27pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/53 "2015-05-12T15:27:10Z")

</div>

> [@186602:@Bob Keeney](#):
>
> FWIW, I believe that they have future plans for Auto that they’ve not revealed to us. They have a few things on the plate to deal with first.

I agree with @Bob Keeney here.

---

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [May 12, 2015, 4:27pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/54 "2015-05-12T16:27:20Z")

</div>

[quote=186646:@Joe Ranieri]Auto uses less memory to store values, preserves type information much better than Variant, and lacks all of Variant’s implicit conversions. What it’s missing is a way to efficiently compare the value’s type to a predetermined type (and do so without using text literals).

I suspect what will end up happening is something like this:

`Select Case Xojo.Introspection.GetType(var)
Case GetTypeInfo(String)
  // Do something
Case GetTypeInfo(Integer)
  // Do something
Case GetTypeInfo(Double)
  // Do something
End Select`[/quote]  
Wouldn’t this be very slow to gather type info for each case statement?

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 4:33pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/55 "2015-05-12T16:33:22Z")

</div>

A bunch of statics you grab once and reuse would work and then you have that hit once

---

<div class="post-metadata">

**Author:** ![Thom\_McGrath](https://forum.xojo.com/user_avatar/forum.xojo.com/thom_mcgrath/32/192_2.png) [@Thom\_McGrath](https://forum.xojo.com/u/Thom_McGrath)\
**Post date:** [May 12, 2015, 4:35pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/56 "2015-05-12T16:35:18Z")

</div>

Or the Xojo.Introspection could do that for us. Have a few common methods such as TextType, DateType, etc that caches for us.

---

<div class="post-metadata">

**Author:** ![KarenA](https://forum.xojo.com/letter_avatar_proxy/v4/letter/k/c89c15/32.png) [@KarenA](https://forum.xojo.com/u/KarenA)\
**Post date:** [May 12, 2015, 4:35pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/57 "2015-05-12T16:35:19Z")

</div>

> [@186644:@Norman Palardy](#):
>
> Personally I’d start with “correct type determination” and then worry about getting it faster, easier and safer

I don’t see how it would be ever possible for introspection to approach the speed of (never mind the simplicity and readability of code using) an integer property.

That is the concern… And I think that practical issue overrides edge case issues with using an integer property in most people’s opinion.

- Karen

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [May 12, 2015, 4:51pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/58 "2015-05-12T16:51:43Z")

</div>

Keep in mind that, right now, GetTypeInfo is an operator, not a function.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 5:39pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/59 "2015-05-12T17:39:56Z")

</div>

> [@186672:@Thom McGrath](#):
>
> Or the Xojo.Introspection could do that for us. Have a few common methods such as TextType, DateType, etc that caches for us.

Sure  
That’d be plausible  
Just saying this this is possible to speed up so you don’t have repeated hits without Introspection doing it.  
But this is predicated on joes “suppose …” post that doesn’t exist today.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [May 12, 2015, 5:40pm UTC](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169/60 "2015-05-12T17:40:58Z")

</div>

[quote=186673:@Karen Atkocius]I don’t see how it would be ever possible for introspection to approach the speed of (never mind the simplicity and readability of code using) an integer property.

That is the concern… And I think that practical issue overrides edge case issues with using an integer property in most people’s opinion.

- Karen[/quote]  
An integer property prevents us from ever doing certain things with Auto  
Things we’re not discussing at this time.  
Really.

[Previous page](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169.md?page=2)

[Next page](https://forum.xojo.com/t/auto-vs-variant-when-to-use-auto/24169.md?page=4)
