Blog post !

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Blog post !

Post by Danilo »

StarBootics wrote:I'm not asking it it will be needed or not. What I'm asking is if it will be possible otherwise 100 000 lines (maybe more) will simply go to waste. That's my point. :evil:
Interfaces are working in SpiderBasic and it is possible in C as well.
It‘s just a struct with vtable with function pointers. ;)
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Blog post !

Post by StarBootics »

Danilo wrote:Interfaces are working in SpiderBasic and it is possible in C as well.
It‘s just a struct with vtable with function pointers. ;)
That good news. Now the only question I have left was about the C standard types including the unsigned long and unsigned long long

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Rinzwind
Enthusiast
Enthusiast
Posts: 638
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Blog post !

Post by Rinzwind »

I also never understood the 'PureBasic' is simple comments. Yes, if you constrict yourself to what it can deliver out of the box and stay with basic programs and samples. Go out of that comfort and you soon bump your head into ugly win32 API's or CocoaMessages because of a missing build-in function or this, that, such so or even... POINTERSSSS the scare of many programming textbooks. I always saw PB as C-like with strong standard libraries and safe strings. It's closer to that then let's say VB6. It's syntax isn't as what I considered to be Basic, hence there is not one Basic.

While I'm at it, my 'negatives' (don't take it too negative):
  1. As above, extend structures to support procedures that handle it's data
  2. For one, I dread the many () used for too many things. Wish the compiler also allowed let's say [] in certain cases (arrays?)
  3. Lack of inline arrays declaration are another ouch-point for me which I think would be easy to fix. Apparently not.
  4. ByVal/ByRef choice for procedures (would make it more Basic rrright? No more messing with those dangerous pointers ;))
  5. Recently: gadget library does not support multi-monitor-DPI situations.. pain to handle it yourself.. combo API and PB libraries..
  6. Gadget library could do with a few additions, for one an advanced table control and some modern styled control variations.
  7. Integer-key Map
  8. Maybe some PB libraries could be open sourced to speed up bug fixes and stuff. Just a thought.
  9. Maybe PB could start an official GitHub repository for 3rd party additional maintained libraries, unit tested and all. A lot of the time people are reinventing the wheel or copying old code hoping it works and is stable.
  10. Windows Callback get messy real quick, add support for something like procedure OnHotKey(wp, lp) message #wm_hotkey . SetWindowCallback can only be called once. What if another modules also needs it (there's the window parameter which helps somewhat)? Target easy reusability.
  11. GUI designer is lacking (multi select actions don't do much). Let us add some custom info to a gadget (maybe GadgetData added to the properties table). It also breaks on scale <> 100%.
Anyway, evolve the parts where it matters.
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Blog post !

Post by Fred »

StarBootics wrote:
We have some questions and no answers yet :cry:

Please Fred ...

Best regards
StarBootics
Why the saddeness ? All PureBasic feature will be supported in the C backend unless proved to be impossible (which is very unlikely). For now, the current limitations are:

- no level to 'Break' (should be resolved somewhen)
- no Gosub (should be resolved soon)
- no label address (?LabelName) outside of Datasection (could be resolved somewhen, not sure if it worths it).

Then that pretty much it, all common stuffs like prototype, interface etc works indeed.

And again: we DON'T plan to drop the current asm backend, plain and simple.
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Blog post !

Post by luis »

Fred wrote: - no label address (?LabelName) outside of Datasection (could be resolved somewhen, not sure if it worths it).
I'm sure some people is using labels in the body of procedures or outside the data section anyway for many tricks or extensions. I'm one of them, I have at least two uses probably more, one is a sort of poor man try/catch and I've used it extensively.
So please try to keep it if possible.

It was actually implemented after a request from 2010
viewtopic.php?f=3&t=42555&hilit=Implemented
and your own idea of implementing it
viewtopic.php?p=320077#p320077

With the new backend will PB continue to generate a single EXE with no additional dependencies to distribute with it (excluding OGRE) ?
Last edited by luis on Fri Mar 19, 2021 12:01 pm, edited 2 times in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
StarBootics
Addict
Addict
Posts: 984
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Blog post !

Post by StarBootics »

Fred wrote:Why the saddeness ? All PureBasic feature will be supported in the C backend unless proved to be impossible (which is very unlikely). For now, the current limitations are:

- no level to 'Break' (should be resolved somewhen)
- no Gosub (should be resolved soon)
- no label address (?LabelName) outside of Datasection (could be resolved somewhen, not sure if it worths it).

Then that pretty much it, all common stuffs like prototype, interface etc works indeed.

And again: we DON'T plan to drop the current asm backend, plain and simple.
The sadness was due to the fact that big changes into a programming language such as the new C Backend can mean big changes into the language it self. I remember when changes in the language in the earlier version of PureBasic (the introduction of Modules for example) was literally a game changer but it also means that the good old ways of writing code as to change as well. I'm not afraid of change, what I'm afraid is regressions.

And you pointed some out that will probably resolved.

Thanks for your answer. :D

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Blog post !

Post by User_Russian »

Fred wrote:no level to 'Break' (should be resolved somewhen)
Why aren't you using goto?
Bkeak 2 can be translated like this in C.

Code: Select all

for (uint8_t i=0; i<10; i++)
{
    for (uint8_t x=1; x<100; i++)
    {
        goto break2; // This Bkeak 2 in PB.
    }
}
break2:;
Fred wrote:no label address (?LabelName) outside of Datasection (could be resolved somewhen, not sure if it worths it).
Why? GCC allows you to find out the address of the label.
See this screenshot.

Image

The label is located at address 0x2000030E and the variable has the same value. Everything works fine.
Fred wrote:no Gosub (should be resolved soon)
Write what difficulties have arisen. It may be possible to find a solution.
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Blog post !

Post by BarryG »

Fred wrote:- no level to 'Break' (should be resolved somewhen)
Hopefully this can be resolved as soon as possible, rather than sometime in the future. It's a major feature to have a Break level, and without this it will ruin a lot of nested loops that currently depend on it. Until this is resolved, I won't even be able to begin testing any new betas because a few of my loops have "Break 2" and "Break 3" in the same processing code.
User avatar
skywalk
Addict
Addict
Posts: 3994
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Blog post !

Post by skywalk »

BarryG wrote:
Fred wrote:- no level to 'Break' (should be resolved somewhen)
Hopefully this can be resolved as soon as possible, rather than sometime in the future. It's a major feature to have a Break level, and without this it will ruin a lot of nested loops that currently depend on it. Until this is resolved, I won't even be able to begin testing any new betas because a few of my loops have "Break 2" and "Break 3" in the same processing code.
Yes, I have many nested loops that Break 2, but no Break 3 as yet.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Blog post !

Post by Fred »

User_Russian wrote:Why aren't you using goto?
Bkeak 2 can be translated like this in C.

Code: Select all

for (uint8_t i=0; i<10; i++)
{
    for (uint8_t x=1; x<100; i++)
    {
        goto break2; // This Bkeak 2 in PB.
    }
}
break2:;
It's the plan, it's just not implemented yet.
User_Russian wrote:
Fred wrote:no label address (?LabelName) outside of Datasection (could be resolved somewhen, not sure if it worths it).
Why? GCC allows you to find out the address of the label.
See this screenshot.

Image

The label is located at address 0x2000030E and the variable has the same value. Everything works fine.
Fred wrote:no Gosub (should be resolved soon)
Write what difficulties have arisen. It may be possible to find a solution.
I know, but it's GCC specific and I would like to avoid this to be able to use other compiler as well. If I get no other choices we could be tied to GCC, but I want to explore all possibilities.
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Blog post !

Post by Saki »

Code: Select all

For i=1 To 10000
  For ii=1 To 10000
    If ii=5000
      ; Break 2
      Goto finish
    EndIf
  Next ii
Next i
finish:
Debug "Finished "+ii
Oh no, the Goto police will be upset again :shock:
地球上の平和
BarryG
Addict
Addict
Posts: 3318
Joined: Thu Apr 18, 2019 8:17 am

Re: Blog post !

Post by BarryG »

@Saki: From the manual for the "Goto" command: To exit a loop safely, you always must use Break instead of Goto. Something about releasing the stack correctly, IIRC.
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Blog post !

Post by TI-994A »

Conditional While/Wend and Repeat/Until loops could easily and elegantly replace multi-level breaks.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: Blog post !

Post by Saki »

@Barry The For next changes only one variable,
if something would be put on the stack, this would give a crash.

Code: Select all

repeat
For i=1 To 10000
  For ii=1 To 10000
    If ii=5000
      ; Break 2
      Goto finish
    EndIf
  Next ii
Next i
finish:
forever
地球上の平和
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: Blog post !

Post by Tenaja »

TI-994A wrote:Conditional While/Wend and Repeat/Until loops could easily and elegantly replace multi-level breaks.
It can be elegant, but if one of the exit conditions is only combined with a handful of other specific conditions (i.e. nested deep in some IF's), placing that whole pile into the conditional loop test can be ugly, confusing, and slower since the condition is tested with every iteration... And is no longer elegant.
Post Reply