New array features

For other topics related to the FreeBASIC project or its community.
speedfixer
Posts: 377
Joined: Nov 28, 2012 1:27
Location: California

Re: New array features

Postby speedfixer » Jul 15, 2019 21:04

I shouldn't reply, but doesn't that reply by you only sound like a troll? Why do that? I would chastise my children if they did that. I am only 67 and only have 300+ posts. Maybe I don't understand the purpose of these forums. I should bow to your higher post count. No more on this for me.
Lost Zergling
Posts: 240
Joined: Dec 02, 2011 22:51
Location: France

Re: New array features

Postby Lost Zergling » Jul 15, 2019 21:56

@speedfixer: from my point of view, Mr Swiss is one of the rare people who can have worse posts than mine, I try to deal with. I remain convinced of the interest of the works around functions "high level", even if it will be partly in competition with a solution that I propose and thus I believe I am respectful of JK's efforts. I feel rather confident with my technical choices (I'm still far from having said my last word ;-) and we are apparently moving towards differentiated choices that will bring a wealth of alternatives: it is not absurd to want Integrate arrays and lists into a generic approach (conceptual), and likewise it is not absurd either to want a generic object approach in the supported types.Perhaps I might be wrong way(if so ones shall explain why),but in the meantime let's go!
Juergen Kuehlwein
Posts: 210
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Postby Juergen Kuehlwein » Aug 14, 2019 12:33

I just pushed my latest version to the repository, as usual you will find it here

The syntax for the array features is now as follows:
'***********************************************************************************************
' array(sort, array)
' array(sort, array, down [, (i1 [, i2 [, ...]]) | pos(i), [, count]])
' array(sort, (array, nocase))
' array(sort, (array1, array2, nocase) [, (i1 [, i2 [, ...]]) | pos(i), [, count]])
' array(sort, (array, nocase), down [, (i1 [, i2 [, ...]]) | pos(i), [, count]])
' array(sort, array, @customsortproc [, (i1 [, i2 [, ...]]) | pos(i), [, count]])
'***********************************************************************************************

'***********************************************************************************************
' array(insert, array, value [, (i1 [, i2 [, ...]]) | pos(i), [, count]])
'***********************************************************************************************

'***********************************************************************************************
' array(delete, array [, (i1 [, i2 [, ...]]) | pos(i), [, count]])
'***********************************************************************************************

'***********************************************************************************************
' i = array(scan, array, for()[, (i1 [, i2 [, ...]]) | pos(i), [, count]]), returns linear index
' for(searchterm [,nocase [,from])
' for(searchterm [,from])
' for(@customproc)
'***********************************************************************************************

'***********************************************************************************************
' i = array(specifier, array), returns requested value as integer, any ptr or boolean
'***********************************************************************************************
' desc = 60 'get descriptor information (only for internal use)
' data 'pointer to the first array element in memory
' dimensions '# of dimensions (same as UBOUND(array, 0)
' total_size 'in bytes
' total_count 'total # of elements in all dimensions
' size 'same as sizeof(array)
' isfixed 'fixed size array
' isdimmed 'dimmed or empty (zero dimensions)
' isattached 'attached or not
'***********************************************************************************************

'***********************************************************************************************
' i = array(pos, array, (i1 [, i2 [,...]])) returns linear (one based) position from (array_)index
' i = array(ptr, array, (i1 [, i2 [,...]])) returns memory ptr for this index
' u = array(index, array, pos) returns array_index
' u = array(index, array, ptr) returns array_index
'***********************************************************************************************

'***********************************************************************************************
' array(attach, array, redim(1 to 5[, 1 to 6 [1, ...]]), memory ptr)
' array(reset, array)
'***********************************************************************************************


There are precompiled executables in the "new" directory(fbc..., libfb(mt)..., please rename and copy to your FB installation. Be sure to make a copy of the original files before replacing them!) you might use - or you must compile them yourself from the sources.

This is still work in progress, there still may be bugs, the code for tests (sytax_test_...) is messy and needs cleaning in many places. Array(scan, ...) basically works, but needs optimization. That is, it can run even faster for all kinds of string types when optimized. USTRING is implemented sometimes, sometimes not. Error handling must be improved, a few things here a few things there ...

Dodicat´s speed test is in "dodicat_sort.bas", for comparing speed you must run one method and outcomment the other one.


Please test! As always, bug reports, critics, ideas for further improvement are welcome


JK
Juergen Kuehlwein
Posts: 210
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Postby Juergen Kuehlwein » Aug 17, 2019 10:01

Array(scan, ...) is optimized now for speed. For running tests you will need "array.bi" and ustring.bi" from the "new" folder!


JK
jj2007
Posts: 1215
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: New array features

Postby jj2007 » Aug 17, 2019 10:14

Code: Select all

gcc version 8.1.0 (2018)
Juergen\fbc-array\new\ustring.bi(53) error 28: Expected pointer in 'TYPE DWSTR extends wstring'
Juergen\fbc-array\new\array.bi(487) error 41: Variable not declared, fb_ArrayCalcPos in 'i = fb_ArrayCalcPos(byval p, byval pptr)'
Juergen\fbc-array\new\array.bi(511) error 9: Expected expression, found 'fb_ArrayCalcPos' in 'i = fb_ArrayCalcPos(byval p, byval pptr)'
Juergen\fbc-array\new\array.bi(535) error 41: Variable not declared, fb_ArrayCalcIdxPos in 'r = fb_ArrayCalcIdxPos(byval p, byval li, i)'
Juergen\fbc-array\new\array.bi(561) error 41: Variable not declared, fb_ArrayCalcIdxPtr in 'r = fb_ArrayCalcIdxPtr(byval p, byval ppos, i)'
Juergen\fbc-array\new\array.bi(654) error 9: Expected expression, found 'typeof' in 'case typeof(USTRING)'
Juergen\fbc-array\new\array.bi(654) error 3: Expected End-of-Line, found 'typeof' in 'case typeof(USTRING)'
Juergen\fbc-array\new\array.bi(715) error 41: Variable not declared, fb_ArraySort in 'function = fb_ArraySort( byval ap, byval sa, byval t, byval cp, byval ai.p, byval ai.li, byval n)'
Juergen\fbc-array\new\array.bi(718) warning 13(0): Function result was not explicitly set
Juergen\fbc-array\new\array.bi(781) error 41: Variable not declared, fb_ArrayReset in 'function = fb_ArrayReset(byval p)'
Juergen\fbc-array\new\array.bi(784) warning 13(0): Function result was not explicitly set
Juergen\fbc-array\new\array.bi(813) error 41: Variable not declared, fb_ArrayAttach in 'function = fb_ArrayAttach(byval p, u, n, byval mp)'
Juergen\fbc-array\new\array.bi(813) error 132: Too many errors, exiting
Juergen Kuehlwein
Posts: 210
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Postby Juergen Kuehlwein » Aug 17, 2019 16:43

There is a new version here - 64 bit should work now too!

For testing please do the following:

1.) You must remove or outcomment lines at the beginning of my test files (still messy) in the "new" folder because these are specific to my IDE and raise an error otherwise. My IDE can do PowerBASIC and FreeBASIC, therefore "compiler freebasic" means, compile using the FreeBASIC compiler. Likewise the #compile ..." statement, tells my IDE which settings to use for the FreeBASIC compiler.

2.) You cannot just compile from fbc_34.exe or fbc_64.exe! You must run fbc.exe in it´s regular environment. That is you must first rename the original fbc.exe, fbrt0.o, libfb.a and libfbmt.a or backup them, where they are located on your machine. Then you must copy fbc_32.exe to fbc.exe, where your original fbc.exe existed. Do the same with fbrt0.o, libfb.a and libfbmt.a (should be in the "lib" subfolder). For 64 bit do the same procedure. Then copy "array.bi" and ustring.bi" to the "inc" subfolders (32 and 64 bit).

Now you can compile and run FreeBASIC files as usual (but with the new binaries and additions).

Please note:
This is just for testing the new features, this is NOT in any way official. I will re-work this into manageable commits, discuss all of this with Jeff and finally make a pull request. This will take it´s time and i´m sure there will be changes, so please play with it, but don´t do build serious work on it!


JK
jj2007
Posts: 1215
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: New array features

Postby jj2007 » Aug 17, 2019 22:43

speedfixer wrote:1 - JK IS attempting to add new features
2 - it is his desire; he is making the effort and not doing it in secret and is inviting the community to help
3 - he has been sensitive to advice and criticism from others - trying to follow any rules suggested to him

You should all be applauding him.

I can echo that. My post above was a bit critical to JK (it's always frustrating to see loads of error messages), but now I see that he seriously tries to create a full new FB version with additional new features. Good luck and thanks for your effort, Juergen.

P.S., @speedfixer: just ignore MrSwiss.
speedfixer
Posts: 377
Joined: Nov 28, 2012 1:27
Location: California

Re: New array features

Postby speedfixer » Aug 18, 2019 1:42

P.S., @speedfixer: just ignore MrSwiss.


I try. But the 'daddy' kicks in when someone is ... well, MY boys don't do that stuff.
Well, never twice!

He (MrSwiss) just got a timeout. Hopefully he can figure out why he feels he has to respond that way.

david
MrSwiss
Posts: 3221
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: New array features

Postby MrSwiss » Aug 18, 2019 6:20

@speedfixer,

I'm definitely NOT one of your boys, neither by age nor otherwise.
So, you might as well keep all your 'daddy modes' to yourself ...
(I've had 3 children, as well as 5 grandchildren the oldest turns 19 this year)
jj2007 just pulled out, a shoe full of mud, in another thread and reacts, as
expected, with a deeply hurt, overinflated ego, like a petulant child.
(just seeking revenge, not very "grown up")
speedfixer
Posts: 377
Joined: Nov 28, 2012 1:27
Location: California

Re: New array features

Postby speedfixer » Aug 18, 2019 7:00

I apologize to everyone for yeilding to my childish reaction.
Last edited by speedfixer on Aug 18, 2019 15:17, edited 1 time in total.
jj2007
Posts: 1215
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: New array features

Postby jj2007 » Aug 18, 2019 8:14

MrSwiss wrote:jj2007 just pulled out, a shoe full of mud, in another thread and reacts, as
expected, with a deeply hurt, overinflated ego, like a petulant child
Damn, sometimes I desperately miss the icons here! Thanks anyways, you made my day :lol: :lol:

Btw when was the last time that you gave us useful code? Just curious ;-)
Juergen Kuehlwein
Posts: 210
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Postby Juergen Kuehlwein » Aug 18, 2019 9:10

Please stop disputing, this only makes trouble and bad mood.

What i would like to know is: was anybody able to compile and run "dodicat_sort.bas", were your results similar to mine? Do you need more explanations, or is it sufficient, what i posted?


@dodicat,

libfb.a and libfbmt.a (mt = multithread) are the run time libraries for fbc.exe. These libraries are put together from files like "array_ubound.o" or "array_sort." (which is one of the files i added). Each .o file is compiled from it´s corresponding .c file in "src\rtlib\". If you want to know what exactly has been added, then take a look into "src\rtlib\fb_array.h" (from "typedef struct _array_index {" line 68, to " array_attached ," line 149). The relevant code files are "array_attach.c", array_calc.c", "array_desc.c", "array_scan.c", array_shift.c" and "array_sort.c".

There is a table at the beginning of "new\array.bi" with a short syntax description. You find sample code in the "new\syntax_test_..." files. Maybe i should add code for demonstrating each of the features.


JK
Juergen Kuehlwein
Posts: 210
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Postby Juergen Kuehlwein » Aug 18, 2019 19:55

I just noticed there was a bug introduced with the latest update. That is, some other code might not run as usual. It´s related to the extra dimension, i added for indicating fixed size arrays and other flags. This will be no problem anymore as soon as Jeff changes the descriptor´s definition, because then this workaround will be obsolete.

Maybe i find a fix for it in the meantime or i wait until i can make use of the changed descriptor.


JK
dodicat
Posts: 5913
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: New array features

Postby dodicat » Aug 18, 2019 21:13

I followed your instructions.
With a fresh copy of fb 64 bit.
1) made your fbc_64.exe into fbc.exe
2) Added your two .bi files to the include folder.
3) Added the fbrt0.o, libfb.a and libfbmt.a

Your array descriptor and insert deletete compiled OK.


But my main interest (your syntax_test_sort.bas ) throws up errors:

-- error 42: Variable not declared, down in 'array(sort, b, down)'
error 1: Argument count mismatch, found 'down' in 'array(sort,a, down)'
error 1: Argument count mismatch, found 'down' in 'array(sort,(a, b), down)'
error 42: Variable not declared, nocase in 'array(sort, (a, nocase), down, (2), 3)'
error 1: Argument count mismatch, found 'down' in 'array(sort,(a, nocase), down, (2), 3)'
. . .
. . .
error 133: Too many errors, exiting

And the dodicat sort
error 42: Variable not declared, nocase in 'array(sort, (l, nocase)) '0.58'

Your new fbc.exe registers as
FreeBASIC Compiler - Version 1.07.0 (08-17-2019), built for win64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
Juergen Kuehlwein
Posts: 210
Joined: Mar 07, 2018 13:59
Location: Germany

Re: New array features

Postby Juergen Kuehlwein » Aug 18, 2019 22:45

Thanks for testing!

The errors indicate that the wrong compiler (not my version) is running. I don´t know how this can happen. Something must be wrong either with your installation or with your implementation (or my explanation for your installation or implementation, maybe i have overlooked something). Whatever - i uploaded my complete fbc 64 bit folder, you may download it from my google drive here: https://drive.google.com/open?id=156Ksi ... ouFhp_YyHJ . You must add "array.bi" and "ustring,bi" to the "\inc" folder or run the test files from the "\new" folder.

I just re-tested 64 bit, for me it runs like a charm. As said in the preceding post there are still problems with this compiler version, but "dodicat_sort.bas" and "syntax_test_sort.bas" definitely work here.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 36 guests