Author Topic: DIM syntax from FreeBASIC  (Read 15940 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
DIM syntax from FreeBASIC
« on: October 29, 2020, 12:13:40 pm »
How outraged would the community be if we borrowed the alternative syntax of DIM from FreeBASIC, so that instead of:

Code: QB64: [Select]

we could:

Code: FreeBasic: [Select]
  1. DIM AS INTEGER a, b, c

As per https://www.freebasic.net/wiki/KeyPgDim

Note that there's nothing being developed in that direction, but it's something that's been in my mind for a while now.

Also notice that it wouldn't be incompatible with former programs, since the existing syntax would remain untouched.

Also notice that both syntaxes can co-exist.

Also notice I haven't checked our DIM parser for the feasibility yet, so this could all be hypothetical in the end.

Let me hear from y'all.
« Last Edit: October 29, 2020, 12:20:32 pm by FellippeHeitor »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: DIM syntax from FreeBASIC
« Reply #1 on: October 29, 2020, 12:23:52 pm »
  • Best Answer
  • @FellippeHeitor   I would love that! I wish I could do that about every time I start using OPTION _EXPLICIT

    EDIT the rest:

    Never mind I just looked at your syntax again ;-))
    « Last Edit: October 29, 2020, 12:27:46 pm by bplus »

    Offline RhoSigma

    • QB64 Developer
    • Forum Resident
    • Posts: 565
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #2 on: October 29, 2020, 12:27:16 pm »
  • Best Answer
  • I guess many people will love it, cause it saves a lot of keystrokes if somebody wanna go the "written" type way. For me personally it won't make any difference, as I'm a hardcore type suffix user.
    Code: QB64: [Select]
    1. DIM a%, b%, c%
    2. 'or even different types in the same DIM line
    3. DIM i%, l&, s!, d#, t$
    My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
    GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
    Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
    Bonus - Blankers, QB64/Notepad++ setup pack

    Offline bplus

    • Global Moderator
    • Forum Resident
    • Posts: 8053
    • b = b + ...
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #3 on: October 29, 2020, 12:31:05 pm »
  • Best Answer
  • Yeah, if it doesn't make old code bad, steal away!

    Offline Dimster

    • Forum Resident
    • Posts: 500
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #4 on: October 29, 2020, 01:15:48 pm »
  • Best Answer
  • I'm not familiar with FreeBasic and your link to same did answer my thoughts on SHARED but I can't seem to find REDIM in FreeBasic. Do you think there could be an issue with Re dimming a FreeBasic Dim'd variable?

    FellippeHeitor

    • Guest
    Re: DIM syntax from FreeBASIC
    « Reply #5 on: October 29, 2020, 01:22:18 pm »
  • Best Answer
  • No issue at all.

    Offline SMcNeill

    • QB64 Developer
    • Forum Resident
    • Posts: 3972
      • View Profile
      • Steve’s QB64 Archive Forum
    Re: DIM syntax from FreeBASIC
    « Reply #6 on: October 29, 2020, 01:26:38 pm »
  • Best Answer
  • I’ve always thought something similar would be nice, but I think it could be a little closer to our existing syntax to use with a few parentheses.

    Instead of:

    DIM AS INTEGER a, b, c

    How about:

    DIM (a, b, c) AS INTEGER, (d, e, f(10)) AS SINGLE

    You’d basically define blocks of variables, delimited by parentheses, all as an unique variable type.
    https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

    FellippeHeitor

    • Guest
    Re: DIM syntax from FreeBASIC
    « Reply #7 on: October 29, 2020, 01:27:23 pm »
  • Best Answer
  • It'd work too. Whichever would be easier to parse internally, really.

    Offline SpriggsySpriggs

    • Forum Resident
    • Posts: 1145
    • Larger than life
      • View Profile
      • GitHub
    Re: DIM syntax from FreeBASIC
    « Reply #8 on: October 29, 2020, 01:30:08 pm »
  • Best Answer
  • Sure! I don't see any problem with that.
    Shuwatch!

    Offline Dimster

    • Forum Resident
    • Posts: 500
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #9 on: October 29, 2020, 01:31:13 pm »
  • Best Answer
  • It's ok I found Redim info in FreeBasic

    Offline Petr

    • Forum Resident
    • Posts: 1720
    • The best code is the DNA of the hops.
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #10 on: October 29, 2020, 01:32:48 pm »
  • Best Answer
  • I'm also for.

    FellippeHeitor

    • Guest
    Re: DIM syntax from FreeBASIC
    « Reply #11 on: October 29, 2020, 02:43:02 pm »
  • Best Answer
  • True!

    Offline Bert22306

    • Forum Regular
    • Posts: 206
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #12 on: October 29, 2020, 06:13:25 pm »
  • Best Answer
  • I don't know if there's an advantage to create a syntax exactly like FreeBasic's, or more similar to C, because otherwise, Steve's idea would be easier to adapt to.

    DIM (a, b, c) as _FLOAT, (d, e, f) as DOUBLE

    Also DIM SHARED, of course, same way.

    It's more like what we do now, but without all the repetition. Yes, this seems like a useful improvement to me too.

    Offline johnno56

    • Forum Resident
    • Posts: 1270
    • Live long and prosper.
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #13 on: October 29, 2020, 06:27:53 pm »
  • Best Answer
  • I think that the change makes 'Dim' simpler to use. My only niggling concern would be, are the changes being made to make QB64 more efficient or to make QB64 more like FreeBasic? Just a thought...
    Logic is the beginning of wisdom.

    Offline TempodiBasic

    • Forum Resident
    • Posts: 1792
      • View Profile
    Re: DIM syntax from FreeBASIC
    « Reply #14 on: October 29, 2020, 07:52:00 pm »
  • Best Answer
  • Hi
    this kind of perspective to let more easyness to type is powerful!
    With Steve's structure maybe that it is easy to manage the syntax by Parser.

    At first time to avoid these writing  I used to put suffix to variables
    but with new QB64 types I  don't like mystyping the suffix  like for example  an _UNSIGNED LONG  becomes a LONG
    so I have put in working the keyword  DEFINT DEFSTR DEFDBL DEFSNG...and in this direction there are the keyword of expansion _DEFINE! This solves with a workaround and limiting the firstletterofVariable.

    This C like and Pascal like feature can be interesting, but is it  expanded to the parameter of the SUB/FUNCTION or there we must type type type like we do now?
    Programming isn't difficult, only it's  consuming time and coffee