Next generation name is FB++ ?

General discussion for topics related to the FreeBASIC project or its community.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Next generation name is FB++ ?

Post by jj2007 »

angros47 wrote:FOR ...EACH, to work properly, should not be implemented like in BlitzBasic (where it cycles on all the elements of a given type), because I might want to cycle on only a part of them
How would you define the subset, syntax-wise? FOR EACH element in SOMESTRING() CONTAINING "sometext" ?
So, the right way to implement it is like in C++, with linked lists. Linked lists are possible, in FreeBasic (they are possible in C, too), but to implement them easily, the best solution would be to have templates (they would allow other structures, too, like maps). And templates are still not implemented in FreeBasic
We had a linked list thread here some time ago.
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: Next generation name is FB++ ?

Post by angros47 »

Not a string... a pointer to the first element of a list.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

angros47 wrote:Not a string... a pointer to the first element of a list.
Correct me if I'm wrong. What you mean requires an object model. For instance some program where all is derived from, say FBAPPLICATION. This master object would have many collections of stuff inside. Like, say, a button collection and so on. If the for each is only specifically dedicated to FBAPPLICTION, then we would have to restrict the loop to this or this given collection inside. I think I already have seen this kind of stuff. Not sure if it's what you mean more or less.
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: Next generation name is FB++ ?

Post by angros47 »

Actually, more of a construct alternative to arrays. Something like:

Code: Select all

List MyList as Integer
MyList.Push_back(1)
MyList.Push_back(1)
MyList.Push_back(2)
MyList.Push_back(3)
MyList.Push_back(5)
MyList.Push_back(8)

For i as integer= each Mylist
   Print I
Next
It would return
1
1
2
3
5
8
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

angros47 wrote:Actually, more of a construct alternative to arrays.
It looks like linked lists forementionned. I suggested this as a primary jet:

Code: Select all

  #macro _FOREACH_(tEnumerator, T)
    dim as T    tEnumerator => t1
    do
#endMacro
#macro _NEXT_(tEnumerator)
    tEnumerator = *tEnumerator._next 
    loop until tEnumerator._next=0
    ? tEnumerator._index
#endMacro

type T      'foreacheable base type
    declare constructor()
    as integer  _index
    as T ptr    _previous
    as T ptr    _next
    static as integer   constructionCounter
    static as T ptr     temporaryPrevious
end type
dim as integer      T.constructionCounter   => 0
dim as T ptr        T.temporaryPrevious     => 0
constructor T()
    T.constructionCounter += 1
    THIS._index         = T.constructionCounter
    THIS._previous      = T.temporaryPrevious
    if T.temporaryPrevious<>0 then
        T.temporaryPrevious->_next = @THIS
    end if
    T.temporaryPrevious = @THIS
end constructor


'''''''''''''''''''''''''''''''''''''''''''
dim as T    t1
dim as T    t2
dim as T    t3
dim as T    t4


_FOREACH_(tEnumerator, T)
    ? tEnumerator._index
_NEXT_(tEnumerator)


getKey()
'(eof)
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: Next generation name is FB++ ?

Post by Lost Zergling »

@angros47 Welcome have a look to "my" LZLE project https://freebasic.net/forum/viewtopic.php?f=8&t=26533 ?
marcov
Posts: 3454
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Next generation name is FB++ ?

Post by marcov »

(I missed this one originally)
caseih wrote:I think you mean lists have an O(n) access time. Arrays and hash tables are O(1), which is very fast.
And lookup is not the only action done on datastructures. If you e.g. iterate you touch all elements, and still the array is faster because memory is non-uniform. The chance that the next item is already in the cache (prefetched) is much larger for an (static) array.
I've used lists on several occasions when I needed a data structure that I could insert nodes into at arbitrary places. I've also occasionally had the need to implement a kind of stack, and the C++ stl list works well for that.
Afaik std:list is usually implemented as a circular buffer in an array to avoid excessive heap operations for every mutation?
Other structures like trees I use all the time, and they are very similar to linked lists. Back in uni I learned all kinds of data structures that I never thought I'd use. Imagine my surprise one day when I found the Left Child Right Sibling tree to be a perfect fit for something I was working on.
I'm fond of B+Trees, specially if the nodes hold value types (because then if links are indexes instead of pointers, you can just memorymap it). Microsoft uses it heavily in its IStorage like fileformat. CHM is internally a derivate of that.

P.s. it would be fun to have a datastructures thread.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Next generation name is FB++ ?

Post by jj2007 »

marcov wrote:CHM is internally a derivate of that.
Not really a recommendation: Loading Help\FB-manual-1.05.0.chm is incredibly slow.
marcov
Posts: 3454
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Next generation name is FB++ ?

Post by marcov »

jj2007 wrote:
marcov wrote:CHM is internally a derivate of that.
Not really a recommendation: Loading Help\FB-manual-1.05.0.chm is incredibly slow.
There is no noticable delay when clicking the CHM here in W10. Maybe your antivirus interferes ?
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Next generation name is FB++ ?

Post by jj2007 »

marcov wrote:
jj2007 wrote:
marcov wrote:CHM is internally a derivate of that.
Not really a recommendation: Loading Help\FB-manual-1.05.0.chm is incredibly slow.
There is no noticable delay when clicking the CHM here in W10. Maybe your antivirus interferes ?
Apparently, it's only the first launch after a reboot that is slow. But I've noticed this slowness several times. It could also be that Windows needs to launch a service to view a CHM file.
caseih
Posts: 2157
Joined: Feb 26, 2007 5:32

Re: Next generation name is FB++ ?

Post by caseih »

jj2007 wrote:
marcov wrote:CHM is internally a derivate of that.
Not really a recommendation: Loading Help\FB-manual-1.05.0.chm is incredibly slow.
Wait what? You are panning B+ trees because you find a particular file slow to load? Wow that's an interesting way to judge the use and speed of data structures and algorithms.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Next generation name is FB++ ?

Post by jj2007 »

caseih wrote:You are panning B+ trees because you find a particular file slow to load? Wow that's an interesting way to judge the use and speed of data structures and algorithms.
I have several interesting and well-tested ways to test the speed of data structures and algorithms. No, in this case I am talking about my experience with the crappy CHM format because markov is fond of it:
marcov wrote:I'm fond of B+Trees, specially if the nodes hold value types (because then if links are indexes instead of pointers, you can just memorymap it). Microsoft uses it heavily in its IStorage like fileformat. CHM is internally a derivate of that.
See also this post of today: Having a problem with help file - masm32.chm
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Next generation name is FB++ ?

Post by dodicat »

I think the .chm format is excellent for freebasic, although not for masm basic obviously with the dot thing.
Rural Scotland (in some parts) has a very slow broadband speed.
I cannot use the freebasic online help without waiting for ages for a page to complete.
Also it seems for a browser to open html is also slow here.(I tested masm basic member Hutch's idea with html to overcome the .chm problem)
I made a mistake purchasing a printer without a wire connection, I can finish a coffee before the first page appears.
I don't really like the idea of every button pressed on a keyboard or page needed to be printed is sent to cyberspace and the big wide world to know about.
marcov
Posts: 3454
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Next generation name is FB++ ?

Post by marcov »

jj2007 wrote:
caseih wrote:You are panning B+ trees because you find a particular file slow to load? Wow that's an interesting way to judge the use and speed of data structures and algorithms.
I have several interesting and well-tested ways to test the speed of data structures and algorithms. No, in this case I am talking about my experience with the crappy CHM format because markov is fond of it
You are quite quick to consider something crappy.
jj2007 wrote: See also this post of today: Having a problem with help file - masm32.chm
I can't reproduce here with 64-bit win10 which works fine for me. The thread also talks of people that can't reproduce, so the whole story is a bit dodgy.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Next generation name is FB++ ?

Post by jj2007 »

marcov wrote:You are quite quick to consider something crappy.
Yes, that's true. After only a few years of bad experience, I immediately consider something crappy! But I am not the only one with that bad habit, see e.g. here:
A CHM topic ID that contains special characters like dots, spaces and a number of other characters is invalid and simply will not work. That is one of the many restrictions of the ancient Microsoft CHM system. (Actually, Windows itself doesn't really support them either, but current versions do a lot of acrobatics to make it look as though it does.)
Btw *.hlp is even more ancient, but it works much better than *.chm. Nevermind, I have no problem with you being fond of trees, you just picked a really bad example. Let's blame Micros**t ;-)
dodicat wrote:I tested masm basic member Hutch's idea with html to overcome the .chm problem
I hope Hutch won't see your post, he doesn't really want to be associated with MasmBasic. First, he is more a PowerBasic fan, and second, he is the guy who created Masm32 and maintains the most important assembler forum worldwide...
Post Reply