Next generation name is FB++ ?

General discussion for topics related to the FreeBASIC project or its community.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Next generation name is FB++ ?

Post by Tourist Trap »

C++ is one of the most popular programming languages available today. Originally called C with Classes, the language was renamed C++ in 1983. It’s an extension of the original C language and is a general purpose object-oriented (OOP) environment.
(BDM’s Coding - Tips, Tricks)
Hello,

if we follow the idea in the above quote from a magazine I'm reading those days, FB with Classes could, should, or would, deserve the name of FB++. Does any secret project of such a new generation of fb compiler has left a clue of its probability to any ear around?

Thanks
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Next generation name is FB++ ?

Post by marcov »

Or FC (one ascii value increase like C->D)

To be honest, such wordplay trying to imitate 1980's lore sounds a bit stale IMHO.
deltarho[1859]
Posts: 4292
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Next generation name is FB++ ?

Post by deltarho[1859] »

Perhaps we can liven things up a bit with a 1.06 release and get everyone on the same footing. <smile>
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: Next generation name is FB++ ?

Post by marcov »

deltarho[1859] wrote:Perhaps we can liven things up a bit with a 1.06 release and get everyone on the same footing. <smile>
You mean FB version 2018r2 ? :-)
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

marcov wrote:Or FC (one ascii value increase like C->D)

To be honest, such wordplay trying to imitate 1980's lore sounds a bit stale IMHO.
True. But it seems to be a constant jurisprudence that adding classes to a language makes a substantial jump. Take Python 2 -> 3. VB6 -> VB.Net. C -> C++ ..etc... (pascal -> delphi)
Maybe anyway in the case of FB, classes have always been a part of the plan, so it's more as we were running a temporary FB--, but it would lead erroneously to think that the current versions miss really anything, which is not right.
deltarho[1859] wrote:Perhaps we can liven things up a bit with a 1.06 release and get everyone on the same footing. <smile>
I only hope that 1.07 will bring us some overloadable FOR EACH instruction.

About FOR EACH x IN y,
A- if y is an array of T, and x a variable of type T, then the array should be read from its lowest bound to the uppers one.
B- if y is a pointer of type T ptr, then the last chunk of bits of the type T should be the next address. This means that this T type should be structured like this. Or the x will not know where to jump next. So the type T that fits well, in my opinion, is made of 2 chunks, a chunk of data, and an integer representative of an address in memory.

I see that like this! I may well be fooled totally ;)
Last edited by Tourist Trap on Jun 20, 2018 18:13, edited 1 time in total.
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: Next generation name is FB++ ?

Post by lizard »

Just normal that a developer wants to develop his programming language further. The original basic BASIC philosophy was "Beginner’s All-purpose Symbolic Instruction Code". OOP was not planned.

Today we have some OOP extensions, who wants to use them can do it. Who dont want it can leave it out. Thats considered freedom. So the complete name is FreeBASIC.

But where should further development go? Creating several build systems with about 70 files each just to produce a makefile? We like the simplicity of BASIC. Thats why we are here. And most dont use OOP in their programs. Because it tends to make programs more difficult to read and slower to execute.

What would be nice to have, extensions that support modern file types like .png, .wav, .ogg and so on, still in the good old BASIC style.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

lizard wrote: about 70 files each just to produce a makefile? We like the simplicity of BASIC. Thats why we are here. And most dont use OOP in their programs. Because it tends to make programs more difficult to read and slower to execute.
But easier to write when things start inflating.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

...is this more or less a for each candidate?

Post by Tourist Trap »

I've a little snippet that wants to show what a FOR EACH could be in the case of something else than an array, as said above:

Code: Select all

 
type T
    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
dim as T    tEnumerator => t1

'emulate a for each
'tEnumerator => t1
do 
    ? tEnumerator._index
    tEnumerator = *tEnumerator._next 
loop until tEnumerator._next=0
? tEnumerator._index
'end of emulation


getKey()
'(eof)
Is it right, or going opposite to for each for some reason?

Let's say yes. Then a udt on which we may use successfully For Each, would have to implement under the hood at the very least, a reference counter, and the basics of linked lists stuff, with some update at object destruction. Well I don't know, it sounds not unreachable at first sight. Yes also the enumerator should initialize at the first index of the linked list. And maybe 2 or 3 details like this ...

Unless I'm wrong, if we introduce U extends T, then U would inherit everything necessary for it to be foreacheable the way depicted above. Sounds even easier. (only missing the syntax...)

Edit, quite uggly syntax fix with some macros:

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)
Last edited by Tourist Trap on Jun 20, 2018 19:45, edited 1 time in total.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Next generation name is FB++ ?

Post by fxm »

Please at least correct your first code:
dim as T tEnumerator
dim as T tEnumerator => t1
'emulate a for each
tEnumerator => t1
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

fxm wrote:Please at least correct your first code:
dim as T tEnumerator
dim as T tEnumerator => t1
'emulate a for each
tEnumerator => t1
Done but I don't see what's the problem? Doing the assignment later or sooner seems ok , no?
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Next generation name is FB++ ?

Post by fxm »

Otherwise, your first code was looping indefinitely.
"default constructor, then let operator" is not equivalent to "implicit copy-constructor alone", because the copy-constructor does not call the default constructor before copying.
(see one of my articles!)
Tourist Trap wrote:
lizard wrote: about 70 files each just to produce a makefile? We like the simplicity of BASIC. Thats why we are here. And most dont use OOP in their programs. Because it tends to make programs more difficult to read and slower to execute.
But easier to write when things start inflating.
!!!
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

fxm wrote:Otherwise, your first code was looping indefinitely.
"default constructor, then let operator" is not equivalent to "implicit copy-constructor alone", because the copy-constructor does not call the default constructor before copying.
(see one of my articles!)
Ah, thanks, I missed that.
I think that the enumerator is not far to be useless. Unless we want to do: for each basetype_instance in all_of_some_derived_type_instance... But I never did such a thing nowhere (I don't think vba accepts that).
Imortis
Moderator
Posts: 1923
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Re: Next generation name is FB++ ?

Post by Imortis »

Tourist Trap wrote:
C++ is one of the most popular programming languages available today. Originally called C with Classes, the language was renamed C++ in 1983. It’s an extension of the original C language and is a general purpose object-oriented (OOP) environment.
(BDM’s Coding - Tips, Tricks)
Hello,

if we follow the idea in the above quote from a magazine I'm reading those days, FB with Classes could, should, or would, deserve the name of FB++. Does any secret project of such a new generation of fb compiler has left a clue of its probability to any ear around?

Thanks
Since FB does not have the ++ operation, the closest FB equivalent is FB+=1 which just looks sloppy.

:-)
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Next generation name is FB++ ?

Post by Tourist Trap »

Imortis wrote:
Since FB does not have the ++ operation, the closest FB equivalent is FB+=1 which just looks sloppy.

:-)
FB+=1 has for result FB+1. Less sloppy.
PaulSquires
Posts: 999
Joined: Jul 14, 2005 23:41

Re: Next generation name is FB++ ?

Post by PaulSquires »

Imortis wrote:
Since FB does not have the ++ operation, the closest FB equivalent is FB+=1 which just looks sloppy.

:-)
Lol, now that one made me smile! Good one, Imortis :-)
Post Reply