FreeBASIC 1.08 Development

For other topics related to the FreeBASIC project or its community.
fxm
Posts: 9984
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Postby fxm » Aug 17, 2020 14:54

@coderJeff,

About the change:
- sf.net #909: reverted changes due sf.net #893: invalid suffixes due to '-lang fb' are now pedantic warning only specified with '-w pedantic' or '-w suffix'

Tested on "fbc_win32_mingw_0594_2020-08-15.zip 2020-08-16 02:21 5.7M" from stw

- Before the change:

Code: Select all

Dim As String text
text$ = "FreeBASIC"
Compiler output:
C:\Users\...\FBIde0.4.6r4_fbc1.07.1\FBIDETEMP.bas(2) error 148: Suffixes are only valid in -lang deprecated or fblite or qb in 'text$ = "FreeBASIC"'
C:\Users\...\FBIde0.4.6r4_fbc1.07.1\FBIDETEMP.bas(2) error 148: Suffixes are only valid in -lang deprecated or fblite or qb, found 'text' in 'text$ = "FreeBASIC"'

- After the change:

Code: Select all

Dim As String text
text$ = "FreeBASIC"
Compiler output:
C:\Users\...\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas(2) warning 45(1): Suffixes are only valid in -lang, deprecated or fblite or qb
C:\Users\...\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas(2) error 148: Suffixes are only valid in -lang deprecated or fblite or qb, found 'text' in 'text$ = "FreeBASIC"'

- One of the compiler's error messages has been well transformed into a warning (which can be masked), but the second error message still remains.
jj2007
Posts: 1724
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Postby jj2007 » Aug 17, 2020 17:25

A long time ago GfaBasic was my favourite dialect. No Dim mystring As String; instead, you just typed my$="Hello", and the editor asked you once if you really wanted a new string variable called "my$". Same for my32bit%=12345. It worked perfectly, I never had a problem with typos, similar names etc.
coderJeff
Site Admin
Posts: 3342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Aug 17, 2020 22:35

Ah, ok. I hoped this would be a quick fix. The following generates a warning and an error because the '$' suffix is getting checked both in the lexer (warning) and the parser (error).

Code: Select all

Dim As String text
text$ = "FreeBASIC"

I need to re-think this because it's becoming band-aids on top on band-aids and not really solving what I want to solve.

1) Suffixes on variables in -lang fb generate error since fbc 0.17.0 from 10+ years ago. I wasn't really thinking of re-enabling suffixes generally.
2) Special cases of MID$, CHR$, etc, used to be allowed in fbc 1.05.0 but became an error in fbc 1.06.0. I want to revert this to a warning only. This is the main point that I think dodicat has mentioned several times.

How fbc parses a suffix is deep within in the compiler logic. The lexer/parser generally allows suffixes on everything, however, they are not always meaningful to the context.

The original bug report describes a deeper symptom of the problem. https://sourceforge.net/p/fbc/bugs/832/
fxm
Posts: 9984
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Postby fxm » Aug 18, 2020 5:21

Yes, the '-lang fb' suffix issue is fixed for keywords, but not for variables.
angros47
Posts: 1737
Joined: Jun 21, 2005 19:04

Re: FreeBASIC 1.08 Development

Postby angros47 » Aug 18, 2020 19:36

Question... is this bug https://sourceforge.net/p/fbc/bugs/923/ being handled?
fxm
Posts: 9984
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Postby fxm » Aug 19, 2020 7:07

It's now OK for the change:
- sf.net #908: check visibility for overloaded operators FOR, NEXT, and STEP
fxm
Posts: 9984
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Postby fxm » Aug 22, 2020 16:14

Tested on "fbc_win32_mingw_0597_2020-08-21.zip 2020-08-22 01:59" from stw
The warning has disappeared but not the error!

Code: Select all

Dim As String text
text$ = "FreeBASIC"
Compiler output:
C:\Users\.....\FBIde0.4.6r4_fbc1.08.0\FBIDETEMP.bas(2) error 148: Suffixes are only valid in -lang deprecated or fblite or qb, found 'text' in 'text$ = "FreeBASIC"'
System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.08.0 (2020-08-21), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)

1) Was that the goal?

2) Should we remove the "-w suffix" compile option that I had already included in the documentation?

3) Should we set back that the "$" suffix for string functions is optional (like for the -lang fblite)?
Last edited by fxm on Aug 22, 2020 18:42, edited 3 times in total.
MrSwiss
Posts: 3633
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: FreeBASIC 1.08 Development

Postby MrSwiss » Aug 22, 2020 16:22

fxm wrote:The warning has disappeared but not the error!

Code: Select all

Dim As String text
text$ = "FreeBASIC"

Well, from my point of view: text <> text$ (should always error).

I think anyway, that the last step (backwards), is not so brilliant an idea:
- now: a lot of explaining necessary (again) where allowed/disalowed ($)
- before, as simple as: 'in lang "fb" = disallowed!' (no exceptions)
dodicat
Posts: 6720
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: FreeBASIC 1.08 Development

Postby dodicat » Aug 22, 2020 18:42

Code: Select all

Dim As String text$
text$ = "FreeBASIC"

It is the basic programming language, the $ suffix or the Dim(ension) keyword.
It was like that for years, I know you could do silly stuff like

Code: Select all

if$ x% then% beep

and that was the problem, but it is just plain silly to tag suffixes haphazardly.
coderJeff
Site Admin
Posts: 3342
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Aug 22, 2020 18:47

I guess it is a backward step, as in, should expect fbc 1.05 behaviour on suffixes.

The overall goal in my opinion is that we should have an upgrade path for source code coming from #lang "qb|fblite" migrating to #lang "fb"

The original patch for the bug in sf.net #832 was a very good attempt, but, ultimately it leads nowhere as I've made multiple patches only to fix the symptoms rather than the root cause. fbc generally expects suffixes in the source code, so we need to work with that, IMHO.

I have a patch in mind to address suffixes in a meaningful way, and '-w pendantic' aka '-w suffix' will be relevant. It's coming. It's a big internal change so I want to make sure I coordinate with other work. The change should at least report on the weird stuff as dodicat points out but not prevent the source from compiling.
jj2007
Posts: 1724
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Postby jj2007 » Aug 23, 2020 0:09

dodicat wrote:

Code: Select all

Dim As String text$
text$ = "FreeBASIC"

It is the basic programming language, the $ suffix or the Dim(ension) keyword.
It was like that for years, I know you could do silly stuff like

Code: Select all

if$ x% then% beep

and that was the problem, but it is just plain silly to tag suffixes haphazardly.

The silly stuff is not a problem, just don't use if$ x% then% beep

Fact is that most if not all BASIC dialects allow a simple Dim My$="Hello World", and that the $ suffix allows an important distinction between strings and non-string variables. It dramatically increases the readability of a source. Not allowing the string suffix is a strange idea, I wonder which ideology is behind that.
marcov
Posts: 3019
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: FreeBASIC 1.08 Development

Postby marcov » Aug 23, 2020 9:42

jj2007 wrote: that the $ suffix allows an important distinction between strings and non-string variables.


It never was for the programmer's benefit, $ and % are just to signal the interpreter to not wrap a variable in a variant-like record for performance reasons(according to the source of Micro Soft Basic V2). Of course then the variable must be typed to avoid crashes (assigning to variant that isn't), so the hungarian type notation ($/%) is entered into the symbol table too. But that is the side-effect rather than the reason. The reason is an ancient kind of a type-inference hint for performance reasons.

Both are fairly pointless in typed compilers.

Or why typing Dim As String My is cooler than Dim My$...


Why make unnecessary shorthand exceptions. What's next, assign every type a char from the unicode table as suffix?

Seriously, there is no need to really remove them, because the burden probably is not that great, but to retroactively make it a "feature" is maybe a bit much.
jj2007
Posts: 1724
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Postby jj2007 » Aug 23, 2020 14:00

marcov wrote:It never was for the programmer's benefit, $ and % are just to signal the interpreter to...
It never was meant for the programmer's benefit, but...
marcov wrote:Why make unnecessary shorthand exceptions. What's next, assign every type a char from the unicode table as suffix?
Being able to see the type of a variable increases the readability of code. Suffixes are very similar to Hungarian notation. Can you imagine MSDN without Hungarian notation?

Code: Select all

HWND CreateWindowExA(
  ExStyle, ClassName, WindowName, Style, X, Y, Width, Height, Parent, Menu, Instance, Param
);
Of course, we know CwEx by heart, and we can guess that *Name points to a string, but there are many instances where the API would be illegible without the little hints provided by the Hungarion notation. For example, in the original version it's called lpParam.

Suffixes are even clearer than HN. GfaBasic, for example, used My$, My32bitint%, My16bitint&, MyBoolean!, MyDouble#. For most of my current uses that would be an overkill, but the strings vs numeric variables distinction is really helpful IMHO.
deltarho[1859]
Posts: 2688
Joined: Jan 02, 2017 0:34
Location: UK

Re: FreeBASIC 1.08 Development

Postby deltarho[1859] » Aug 23, 2020 14:36

Sometimes suffixes are essential.

Code: Select all

Print 1234567*1234567
Print 1234567ull*1234567
Sleep

gives

Code: Select all

-557712591
1524155677489

in 32-bit. In 64-bit we are OK.
angros47
Posts: 1737
Joined: Jun 21, 2005 19:04

Re: FreeBASIC 1.08 Development

Postby angros47 » Aug 23, 2020 15:52

Is there any plan to include the coroutines, and the sound library?

Coroutines:
https://freebasic.net/forum/viewtopic.php?p=270146

Sound library:
https://sourceforge.net/projects/freebasic-sfx-library/files/

(I don't know how to modify the compiler to include new commands for them. Also, not sure if the coroutines should be a separate module or included in the runtime library)

Return to “Community Discussion”

Who is online

Users browsing this forum: JJFlash and 5 guests