Author Topic: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)  (Read 2950 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

FellippeHeitor

  • Guest
New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
« on: January 26, 2021, 10:51:50 am »
After the topic was discussed at https://www.qb64.org/forum/index.php?topic=3182.msg124506#msg124506, this new feature has finally made it into the development build.

(Get the dev build generated on 2021-01-26, from git 35e7b22 at https://www.qb64.org/portal/development-build/)

I ask you faithful beta-testers to help me find bugs with the new syntax. With it, this:
Code: QB64: [Select]
can be simplified into:
Code: QB64: [Select]
  1. DIM AS INTEGER a, b, c, d

The same improvement is valid for REDIM, STATIC, COMMON, SHARED as variable-declaring statements. It has also been extended to TYPE. With it, this:

Code: QB64: [Select]
  1. TYPE object
  2.     id AS LONG
  3.     value AS LONG
  4.     x AS SINGLE
  5.     y AS SINGLE
  6.     z AS SINGLE
  7.     w AS INTEGER
  8.     h AS INTEGER
  9.  
can be simplified into:
Code: QB64: [Select]
  1. TYPE object
  2.     AS LONG id, value
  3.     AS SINGLE x, y, z
  4.     AS INTEGER w, h

I did extensive testing locally, but you guys sure can help find approaches I didn't think of. Please let me know if any issues arise as this is the first implementation and, of course, bugs are prone to to have been introduced.

Notice that the traditional syntax remains unchanged and can co-exist with the new syntax freely.

Also, notice that when you use DIM AS type variable-list, you cannot have another AS type clause in the same line.

The new feature won't touch SUB/FUNCTION parameters.

Looking forward to getting results back from your testing.
« Last Edit: January 26, 2021, 11:58:44 am by FellippeHeitor »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
« Reply #1 on: January 26, 2021, 11:12:43 am »
Why not just...

DIM AS INTEGER a - d

That way, I don't have to type the b and the c. It would help, because I get tired after typing all of those AS UDT lines. :D

Nice addition. I'm definitely getting the 1.5 version.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
« Reply #2 on: January 26, 2021, 12:09:50 pm »
Quote
Also, notice that when you use DIM AS type variable-list, you cannot have another AS type clause in the same line.

I assume this also checks for type symbols, or would they be a problem?

DIM AS INTEGER a, b, c, d!, e#, f##
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

FellippeHeitor

  • Guest
Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
« Reply #3 on: January 26, 2021, 12:57:31 pm »
Type symbols are not accepted since you begin by setting the type with the AS clause. The IDE will tell you it's not allowed.

Marked as best answer by on Today at 05:28:40 am

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
« Reply #4 on: January 26, 2021, 01:27:00 pm »
  • Undo Best Answer
  • Version 1.6...

    From

    SUB Pete (a AS INTEGER, b AS INTEGER, c AS INTEGER, d AS INTEGER)

    to...

    SUB Pete (AS INTEGER a, b, c, d)

    If you need any help with this, CALL Pete().

    Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

    FellippeHeitor

    • Guest
    Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
    « Reply #5 on: January 26, 2021, 03:50:21 pm »
    😂

    Offline Pete

    • Forum Resident
    • Posts: 2361
    • Cuz I sez so, varmint!
      • View Profile
    Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
    « Reply #6 on: January 26, 2021, 03:54:12 pm »
    Does that mean you're considering it?????

    Pete
    Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

    FellippeHeitor

    • Guest
    Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
    « Reply #7 on: January 26, 2021, 03:58:08 pm »
    I considered it humorous.

    Well, jokes aside, we've gone over the exclusion of sub/function parameters in the original topic, and we're sticking with it for now.

    Offline Pete

    • Forum Resident
    • Posts: 2361
    • Cuz I sez so, varmint!
      • View Profile
    Re: New DIM/REDIM/STATIC/SHARED/COMMON/TYPE syntax (v1.5)
    « Reply #8 on: January 26, 2021, 04:05:53 pm »
    Gotcha! But hey, if it weren't for those darn commas being needed as parameter separators... :D :D :D

    Hey joking aside, I'm glad the modifications worked out. There are a lot of conditions that have to be checked and successfully passed to do this stuff, including the IDE work, a Steve concern, which thankfully you guys have already addressed. I do look forward to using this. In fact, I intend to retrofit it into my previous programs.

    Pete
    Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/