Author Topic: Proposed change to QB64 regarding CONST  (Read 8061 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Proposed change to QB64 regarding CONST
« Reply #15 on: October 21, 2018, 11:43:11 am »
Steve, do you make 1 BI for the 3 combined libraries or attempt to use the 3 BI's (separate and independent) already ready?

I think you attempt the latter choice and I think the former choice would solve the issue.

It's clear to me, both Fellippe and STxAxTIC are intuitively against the idea though The Disaster Example has not yet been presented.

So the conservative move is probably to wait ie for The Disaster Example to raise it's ugly head.

Constants don't use Type so that can't be a problem either unlike SHARED.

« Last Edit: October 21, 2018, 11:52:29 am by bplus »

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Proposed change to QB64 regarding CONST
« Reply #16 on: October 21, 2018, 11:55:28 am »
If this is mainly about al that CONST TRUE.... thing, then i'm glad to use literal numbers in my libraries. Typing 0 or -1 is shorter than typing TRUE or FALSE.
However, the approch seems ok to me, if the CONST's name AND value are equal, then just ignore the double definition. But maybe it should be restricted to equal literal values only, not if the CONST's value is based on an expression or function result?
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 TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Proposed change to QB64 regarding CONST
« Reply #17 on: October 21, 2018, 01:18:23 pm »
Hi

question: Do we teach to parser to ignore duplication of statement about CONST if they are made the same definition (for name and value)?
summarizing the different opinions showed until now:

let's make Pro and Cons
Pro
- no headache for error that are no error (a CONST doesn't change)
- high feasibility to combine library of different authors and/or ispirations

Cons
- no documentated  feature of BASIC language
- if we change one definition of CONST we fall in the issue of duplicate of name because the others are not already changed so we must search the others to change

other options...
--  make a strong changement of QB64 using
Quote
$IF TRUESET = FALSE THEN
    CONST TRUE = -1, FALSE = 0
    $LET TRUESET = TRUE
$END IF
and making a not backward compatibility with previous code.

This can be a feature of compiler activable by settings in menu (this can solve the backward compatibility issue)

-- create a .BI with only UNIVERSAL CONST from TRUE, FALSE... to OPENED, CLOSED, LOCKED, IS_DIGIT, IS_STRING  as a global constant file as heat of each program coded in QB64. Just like Steve's .BI for COLOR costants.

-- we can teach to parser/compiler to jump to translate (or to REM) the duplicates of CONSTs, so if coder likes  he doesn't care of duplication of the CONST otherwise he go down to delete duplications


Just a my real dubt
Does C++ compiler accept duplicate of CONST?

Thanks to read
Programming isn't difficult, only it's  consuming time and coffee

Offline freetrav

  • Newbie
  • Posts: 45
    • View Profile
Re: Proposed change to QB64 regarding CONST
« Reply #18 on: October 22, 2018, 08:50:26 am »
I'm going to suggest a "meet me halfway" sort of response, splitting the difference between those who say "Yes, ignore a redefined CONST if the value is the same", and "No, throw an error on a redefined CONST no matter what": If the value is the same, throw a WARNING, but let code generation proceed normally. If possible, when throwing the warning, identify the file and line number where it was first defined.

FellippeHeitor

  • Guest
Re: Proposed change to QB64 regarding CONST
« Reply #19 on: October 22, 2018, 09:30:43 am »
Sorry we didn’t proceed with discussion here. We did come to that solution in the chatroom in the end.

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Proposed change to QB64 regarding CONST
« Reply #20 on: October 22, 2018, 02:38:19 pm »
Chatroom is #qb64 on irc.freenode.net

Come one, come all, stay the rest of your days!
You're not done when it works, you're done when it's right.