• Print

Author Topic: 'dim var as long' vs. var& and implicit declaration  (Read 593 times)

codeguy

  • Hero Member
  • *****
  • Posts: 3552
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: 'dim var as long' vs. var& and implicit declaration
« Reply #15 on: August 25, 2010, 01:23:12 PM »
whoops! my bad, it's just like the iterative version in my sorting demos. i would recommend just using the suffixes until this bug gets squashed. i think it's because qb64 has to determine each time what kind of variable it's working with because no absolutely defined (with suffixes) variable types are being used. it's a context thing. say if you're using the statement a=a+b, you can't tell just by looking at that whether a and b are strings or numbers, so qb64 has to resolve this and that's where i think the slowdown is coming from.
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

Zom-B

  • Hero Member
  • *****
  • Posts: 545
Re: 'dim var as long' vs. var& and implicit declaration
« Reply #16 on: August 25, 2010, 02:11:12 PM »
No the slowdown doesn't come from THAT.

QB64 needs to figure out what data types they are, so compilation might be a fraction slower, but once compiled, it is the same code.

The only difference is the event checking at the start of the function. Check it yourself. Paste the two examples (slow and fast ones) into two instances of QB64, and compare the contents of both main.c in their respective temp directories.

codeguy

  • Hero Member
  • *****
  • Posts: 3552
  • what the h3ll did i name that code?
    • stuff at dkm
    • Email
Re: 'dim var as long' vs. var& and implicit declaration
« Reply #17 on: August 25, 2010, 02:37:00 PM »
but shouldn't that only slow it down by the amount of time it takes to execute the single DIM calls, which should be negligible on a fast computer? or is it that dynamically creating variables is slowing this down?
http://denteddisk.forums-free.com/make-an-appointment-with-the-resident-code-guru-f34.html

Zom-B

  • Hero Member
  • *****
  • Posts: 545
Re: 'dim var as long' vs. var& and implicit declaration
« Reply #18 on: August 25, 2010, 03:46:07 PM »
In theory, yes (the former). There should be no measurable slowdown.

  • Print