FreeBASIC 1.08 Development

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

Re: FreeBASIC 1.08 Development

Postby fxm » Aug 30, 2020 6:25

Following this last change:
- Should I remove the "-w suffix" compile option that I had already included in the documentation? Presently it has no longer effect.
- Should I set back that the "$" suffix for string functions in -lang fb induces a warning?
marcov
Posts: 3010
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: FreeBASIC 1.08 Development

Postby marcov » Aug 30, 2020 9:39

Note that allowing $ in the symbol table might force it creeping back into non legacy code via inter module connections, Since an exported symbol must then be match in the spelling. IOW if you declare A$ in module A and export it, if it is in the symbol table as A$ and mangled as such, module B must also refer to it as A$, and not just the equivalent of "string A"

While if you put s$ in the table the same as "string s" that makes multi dialect programs easier.
angros47
Posts: 1673
Joined: Jun 21, 2005 19:04

Re: FreeBASIC 1.08 Development

Postby angros47 » Aug 30, 2020 10:42

Regarding the sound library and the coroutines, is there any plan to integrate them?
coderJeff
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Aug 30, 2020 15:13

fxm wrote:Following this last change:
- Should I remove the "-w suffix" compile option that I had already included in the documentation? Presently it has no longer effect.
- Should I set back that the "$" suffix for string functions in -lang fb induces a warning?


Please continue to include '-w suffix'. If the compiler work is not finished by next release, we can remove it then; from 'fbc -help -v' too.

The intent I have is that built-in string functions with '$' suffix should have no warning unless '-w suffix' was given. Currently only works properly with the quirk stuff - MID$, MK..$, TRIM$, etc. It doesn't work right with the other built-ins like LEFT$, COMMAND$, SPACE$, etc. I have to finish the work on identifiers (the 15 or so cases) before '-w suffix' has some consistency.

Try this with / without '-w suffix'

Code: Select all

print chr$(65)         '' warning only with '-w suffix' | '-w pedantic'
print left$( "", 1 )   '' always warning - I want to change so only warn '-w suffix' | '-w pedantic'


Writing the compiler tests is quite tedious. There's some other changes I want to get added next that might help writing the tests.
coderJeff
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Aug 30, 2020 15:24

angros47 wrote:Regarding the sound library and the coroutines, is there any plan to integrate them?


I don't know about the coroutines. It looks like a library+header would be enough to add. Frankly, it feels like too much for me to promise to do it. What's needed in the compiler? Auto-injecting yields()?

I'm still interested in the sound library. I only have so much time to do things. It would be nice to start with the absolute minimum, especially if I end up the only one to maintain it. Can start with a library+header. What 'things' have to be specifically be added to the fb language / compiler?
D.J.Peters
Posts: 8172
Joined: May 28, 2005 3:28
Contact:

Re: FreeBASIC 1.08 Development

Postby D.J.Peters » Aug 30, 2020 15:27

angros47 wrote:Regarding the sound library and the coroutines, is there any plan to integrate them?
But only as include no more reserved words please !

Thank you

Ing. Dr. Dr. Prof. of absolutely nothing

Joshy
jj2007
Posts: 1692
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Postby jj2007 » Aug 30, 2020 15:38

coderJeff wrote:What 'things' have to be specifically be added to the fb language / compiler?
Say "Hello World"
Say FileRead$("Readme.txt")
Say NoTag$(FileRead$("https://www.freebasic.net/forum/viewtopic.php?f=17&t=27889&start=150"))

The last one works fine - in MASM Assembly ;-)
Last edited by jj2007 on Aug 30, 2020 15:42, edited 1 time in total.
fxm
Posts: 9938
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Postby fxm » Aug 30, 2020 15:42

coderJeff wrote:The intent I have is that built-in string functions with '$' suffix should have no warning unless '-w suffix' was given. Currently only works properly with the quirk stuff - MID$, MK..$, TRIM$, etc. It doesn't work right with the other built-ins like LEFT$, COMMAND$, SPACE$, etc

These warnings will must also be masked in '-lang qb' or '-lang fblite', and this even with '-w suffix' compile option activated.
angros47
Posts: 1673
Joined: Jun 21, 2005 19:04

Re: FreeBASIC 1.08 Development

Postby angros47 » Aug 30, 2020 16:54

coderJeff wrote:I don't know about the coroutines. It looks like a library+header would be enough to add. Frankly, it feels like too much for me to promise to do it. What's needed in the compiler? Auto-injecting yields()?


A precompiled library+header might be enough, although I suggest to add the library to the FB runtime (if coroutines are not used, they would likely not even be linked anyway, so it shouldn't bloat the final binary), and to add to the compiler just the commands of the header. I suggest it just because other languages (like the latest version of C++) are supposed to support coroutines at compiler level, and not as an external library, so it would be nice if FreeBasic, too, had a native support for coroutines (although this is my personal opinion). Or perhaps an intermediate solution could be to just add coroutines to the runtime module, and make them callable with a specific header (as it is already true for the C runtime libraries). It would still mean having native support for coroutines in FreeBasic.


I'm still interested in the sound library. I only have so much time to do things. It would be nice to start with the absolute minimum, especially if I end up the only one to maintain it. Can start with a library+header. What 'things' have to be specifically be added to the fb language / compiler?


Library+header could work, in general, since the sound commands don't have the quirky syntax of, for example, the graphic commands. The main change that I would recommend to the compiler is to provide a sort of "legacy mode" to automatically link the library, and automatically initialize the sound mode and the midi mode, if the commands PLAY and SOUND are used in the -lang QB mode. Also, in -lang QB, the command SOUND freq, duration should be remapped to SOUND PulseWave (freq), duration (QBasic always produced a square wave, so it offered no way to produce other waveforms)
coderJeff
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Aug 30, 2020 18:35

Latest change from https://github.com/freebasic/fbc/pull/231

Changed:
macros and defines can be invoked without parens

Added:
__FB_UNIQUEID_PUSH__(ctx) to create new stack / next unique identifier with respect to ctx
__FB_UNIQUEID__(ctx) to retrieve unique identifier at top of stack
__FB_UNIQUEID_POP__(ctx) to pop top of stack or release stack when empty
__FB_ARG_LEFTOF__(arg,sep) to get the left of separator of a macro argument
__FB_ARG_RIGHTOF__(arg,sep) to get the right of separator of a macro argument
__FB_ARG_COUNT__(args...) to count the number of arguments in a list
__FB_JOIN__(arg1,arg2) to join two macro arguments together

I'm sure I will get questions. Please feel free to start a new topic. Part of this is from v1tor's pulll request from a couple years, and part of this involves some concepts from Juergen Kuehlwein's pull request for macro changes. I wish I had these changes 2 years ago as it would have made rewriting the test-suite a little easier.
robert
Posts: 122
Joined: Aug 06, 2019 18:45

Re: FreeBASIC 1.08 Development

Postby robert » Aug 31, 2020 4:40

coderJeff wrote:Latest change from https://github.com/freebasic/fbc/pull/231

Changed:
macros and defines can be invoked without parens

Added:
__FB_UNIQUEID_PUSH__(ctx) to create new stack / next unique identifier with respect to ctx
__FB_UNIQUEID__(ctx) to retrieve unique identifier at top of stack
__FB_UNIQUEID_POP__(ctx) to pop top of stack or release stack when empty
__FB_ARG_LEFTOF__(arg,sep) to get the left of separator of a macro argument
__FB_ARG_RIGHTOF__(arg,sep) to get the right of separator of a macro argument
__FB_ARG_COUNT__(args...) to count the number of arguments in a list
__FB_JOIN__(arg1,arg2) to join two macro arguments together

I'm sure I will get questions. Please feel free to start a new topic. Part of this is from v1tor's pulll request from a couple years, and part of this involves some concepts from Juergen Kuehlwein's pull request for macro changes. I wish I had these changes 2 years ago as it would have made rewriting the test-suite a little easier.


Hi CoderJeff:

You probably know about this, but I thought I would mention it anyway, just in case.

On Windows 10 unit-tests

Code: Select all


fbc.exe -c -w 3 -i fbcunit/inc -m fbc-tests -mt pp/macro_arg_count.bas
pp\macro_arg_count.bas(6) error 42: Variable not declared, __FB_ARG_COUNT__ in 'CU_ASSERT_EQUAL( 0, __FB_ARG_COUNT__( ) )'



If this is not the appropriate place for this message, please point out to me to the correct location.
coderJeff
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Aug 31, 2020 11:46

robert wrote:

Code: Select all

fbc.exe -c -w 3 -i fbcunit/inc -m fbc-tests -mt pp/macro_arg_count.bas
pp\macro_arg_count.bas(6) error 42: Variable not declared, __FB_ARG_COUNT__ in 'CU_ASSERT_EQUAL( 0, __FB_ARG_COUNT__( ) )'


Ensure that the newly built compiler is what's being tested. If invoking with the makefile(s), can pass FBC=d:/path/fbc.exe to explicitly tell which exe to use. 'FBC' environment variable and 'PATH' can override which fbc is invoked. Can use 'fbc -version -v' to see exact source your fbc.exe was built with. As of 2020-08-31, should be 'e1a25ee...', assuming no other patches or changes applied compared to freebasic/fbc/master.
robert
Posts: 122
Joined: Aug 06, 2019 18:45

Re: FreeBASIC 1.08 Development

Postby robert » Aug 31, 2020 19:04

coderJeff wrote:
robert wrote:

Code: Select all

fbc.exe -c -w 3 -i fbcunit/inc -m fbc-tests -mt pp/macro_arg_count.bas
pp\macro_arg_count.bas(6) error 42: Variable not declared, __FB_ARG_COUNT__ in 'CU_ASSERT_EQUAL( 0, __FB_ARG_COUNT__( ) )'


Ensure that the newly built compiler is what's being tested. If invoking with the makefile(s), can pass FBC=d:/path/fbc.exe to explicitly tell which exe to use. 'FBC' environment variable and 'PATH' can override which fbc is invoked. Can use 'fbc -version -v' to see exact source your fbc.exe was built with. As of 2020-08-31, should be 'e1a25ee...', assuming no other patches or changes applied compared to freebasic/fbc/master.


Hi CoderJeff:

Thank you for the advice. I recloned from Github, recompiled and retested. The failure posted above no longer occurs.
coderJeff
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Sep 05, 2020 23:48

dang it. First bug I found on the macro changes:
fbc doesn't recognize start of argument list versus argument in parens. In theory it shouldn't break any existing code, since all existing code will have parens to invoke macros.

Code: Select all

#macro m( a, b )
   print a, b
#endmacro

sub s( byval a as integer, byval b as integer )
   print a, b
end sub

s   1,  2   '' OK
s ( 1,  2 ) '' OK
s   1, (2)  '' OK
s  (1), 2   '' OK

m   1,  2   '' OK
m ( 1,  2 ) '' OK
m   1, (2)  '' OK
m  (1), 2   '' argument count mismatch


In one of JK's pull requests he had ideas to only allow the optional parens in certain places. Maybe.... But, I was thinking more along the lines of something added to the #macro definition itself to decide if parens should be optional.

I was working on writing tests for __FB_QUOTE__(arg), __FB_UNQUOTE__(arg), and __FB_EVAL__(expr) and starting see behaviours I don't want.
coderJeff
Site Admin
Posts: 3308
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Postby coderJeff » Sep 06, 2020 16:13

A few more bugs fixed with the initial add - I guess I should have wrote a few more tests. Fix-ups are merged in.

I started a thread in documentation forum about the new built-ins, to give an idea what they are supposed to do.
Basic-Macros in fbc 1.08

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests