FreeBASIC 1.08 Development

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
Pim Scheffers
Posts: 54
Joined: Jun 29, 2014 17:15

Re: FreeBASIC 1.08 Development

Post by Pim Scheffers »

Getting more and more excited for 1.08 :-)

Great work!
marcov
Posts: 3462
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: FreeBASIC 1.08 Development

Post by marcov »

coderJeff wrote: __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
I can get the count, but it must be 1 or 2, since I can only get the right or the left, but no way to get list item 2 (the middle one) when there are 3 items?

FB_ARG_MIDOF__(arg,sep,cnt) ? :-)
coderJeff
Site Admin
Posts: 4323
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

marcov wrote:FB_ARG_MIDOF__(arg,sep,cnt) ? :-)
I was thinking about something similar, like getting the N-th argument. But there's some technical limitations on how fbc handles variadic argument lists under the hood, making this actually quite difficult without some major modifications.

Thanks, a few thoughts:
- Maybe I should have named the argument counting macro as __FB_COUNT_ARGS__( args... ), as it can expect a list of arguments, either empty, or separated with fbc's argument separator: the comma ',' and respects parentheses levels '(' ... ')' for any expressions.
- the 'leftof' and 'rightof' macros work on a **list of tokens**, as would be in a single argument: 'arg' may contain comma and parentheses, but have no special meaning to 'leftof' and 'rightof' operation.

As I have time I'll try add some more info and details to Basic-Macros in fbc 1.08.
coderJeff
Site Admin
Posts: 4323
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

Dang, another bug with the optional parens() feature. Have to fix this one for sure as can break existing code.

Code: Select all

#define X(arg) some expr
Type T
	X as integer  '' <<< error
End Type
It's due the symbol name look ups. Previous only 'X(' could indicate the macro, but now because parens are optional, causes disaster.

So, I'm thinking of something like:

Code: Select all

#macro somename ? ( arg1, arg2, args... )
	'' ...
#endmacro
Using '?' to indicate default parens() only, Otherwise, macros and defines just work like they always did by default. Though I'm not crazy about the syntax, I could at least leave the feature alone for a knowing it's not breaking any existing code.
RockTheSchock
Posts: 252
Joined: Mar 12, 2006 16:25

Re: FreeBASIC 1.08 Development

Post by RockTheSchock »

I had some ideas a while ago making macros much more powerfull. Introducing some macro statements for context handling would be great.

viewtopic.php?f=2&t=28465&p=270769#p270769
fxm
Moderator
Posts: 12107
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: FreeBASIC 1.08 Development

Post by fxm »

fxm wrote:
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.
It might be nice to complete the fbc update for anything related to the "$" suffix.
I'm waiting for this to update the documentation (21 keywords impacted).
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Re: FreeBASIC 1.08 Development

Post by jevans4949 »

Will the 1,08 release include the gas64 option?
SARG
Posts: 1763
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.08 Development

Post by SARG »

jevans4949 wrote:Will the 1,08 release include the gas64 option?
CoderJeff and I are working on that.
Why are you interested ?
jevans4949
Posts: 1186
Joined: May 08, 2006 21:58
Location: Crewe, England

Re: FreeBASIC 1.08 Development

Post by jevans4949 »

SARG wrote:
jevans4949 wrote:Will the 1,08 release include the gas64 option?
CoderJeff and I are working on that.
Why are you interested ?
Been trying to work out how to use it. Have a few modules which have simple 32-bit routines, although I will probably need to re-wite these.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FreeBASIC 1.08 Development

Post by D.J.Peters »

I'm waiting so long for !
wInkey() we have wString but no wString input :-(
(it makes no sense to write an editor or a GUI complete in FreeBASIC without unicode or UTF user input !)

For shader code or any script language, Lua, OpenCL, libtcc, libsquirrel ... we need vebatim strings.
(ignore CR and LF inside a string thats all)
var code = "main () {
source code;
source code source code source code;
mopre source code;
source code source code;
source code; }"

I saw and use in a modern language "spin" underscore '_' in any literal number are allowed and I like it.

var myNmber = &H00_CAFFEE_DEAD_BEEF
vat myBitmask = &B1010_0011_1010_0000_11111111_1100
var myDec = 100_000
var myFloat = 2_600_000.5

Joshy
Last edited by D.J.Peters on Sep 10, 2020 0:04, edited 1 time in total.
SARG
Posts: 1763
Joined: May 27, 2005 7:15
Location: FRANCE

Re: FreeBASIC 1.08 Development

Post by SARG »

jevans4949 wrote:Been trying to work out how to use it. Have a few modules which have simple 32-bit routines, although I will probably need to re-wite these.
Currently the provided version of the exe can be used as the 32bit version of fbc : asm code is directly emitted. Just replace fbc by fbc64_gas64.
In the future adding of the option -gen gas should be necessary.
About your existing routines more than probable.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Post by jj2007 »

D.J.Peters wrote:For shader code or any script language, Lua, OpenCL, libtcc, libsquirrel ... we need vebatim strings.
(ignore CR and LF inside a string thats all)
var code = "main () {
source code;
source code source code source code;
mopre source code;
source code source code;
source code; }"
Interesting idea.You could realise it with a filter/preprocessor that checks for lines with only one quote. I am surprised, though, that line continuation doesn't work with literal strings:

Code: Select all

var code = "main () {"
code=code+Chr(13, 10)+"source code;"
code=code+Chr(13, 10)+"source code source code source code;"
code=code+Chr(13, 10)+"more source code;"
code=code+Chr(13, 10)+"source code source code;"
code=code+Chr(13, 10)+"source code; }"
Print code

#if 0 ' strangely enough, these are not allowed:
code=code+Chr(13, 10, "source code;")	' error 58: Type mismatch

code="Line _
continuation _
does not work _
with strings"

#endif
angros47
Posts: 2323
Joined: Jun 21, 2005 19:04

Re: FreeBASIC 1.08 Development

Post by angros47 »

Code: Select all

code="Line "+_
"continuation "+_
"can actually work "+_
"with strings"
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: FreeBASIC 1.08 Development

Post by jj2007 »

angros47 wrote:

Code: Select all

code="Line "+_
"continuation "+_
"can actually work "+_
"with strings"
Right, that works (although it remains somewhat clumsy):

Code: Select all

asm int 3
code="Line "+_
Chr(13, 10)+"continuation "+_
Chr(13, 10)+"can actually work "+_
Chr(13, 10)+"with strings"
asm nop
... and it's even OK under the hood, the compiler works with one single string:

Code: Select all

   int3
   push 0
   push 37
   push offset 0040608C               ; ³Arg3 = ASCII "Line ",CR,LF,"continuation ",CR,LF,"can actually work ",CR,LF,"with strings"
   push -1
   lea eax, [ebp-10]
   push eax
   call 00401CD0                                        ; create the string
   nop
coderJeff
Site Admin
Posts: 4323
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: FreeBASIC 1.08 Development

Post by coderJeff »

With /' ... '/ used for multi-line comments, maybe /" ... "/ for multi-line strings -- for some symmetry.
Post Reply