Blog post !

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
skywalk
Addict
Addict
Posts: 3532
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Blog post !

Post by skywalk »

Agreed.
Break n is concise and to the point.
Refactoring nested For Loops with complex conditionals is a nightmare.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
TI-994A
Addict
Addict
Posts: 2490
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore

Re: Blog post !

Post by TI-994A »

Tenaja wrote: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.
In well-structured code, conditional loops should always prove to be the most elegant approach.
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!
User avatar
Danilo
Addict
Addict
Posts: 3010
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Blog post !

Post by Danilo »

Fred wrote:
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.
Maybe you can add an internal break_level for inner loops?

Code: Select all

#include <stdio.h>

unsigned long long break_level;

#define break_with_level(level) break_level=level-1; break;
#define check_break_level       if(break_level>0) { break_level--; break; }

int main() {

    break_level = 0; for (int i=0; i<10; i++) {

        break_level = 0; for (int j=0; j<10; j++) {

            break_level = 0; for (int k=0; k<10; k++) {

                break_with_level(3);

                printf("end of k loop\n");
            }
            check_break_level;

            printf("end of j loop\n");

        }
        check_break_level;

        printf("end of i loop\n");

    }


    return 0;
}
Emit 'check_break_level' only after inner loops.
User avatar
StarBootics
Enthusiast
Enthusiast
Posts: 695
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Blog post !

Post by StarBootics »

Hello everyone,

I have some questions about some stuff since C compilers are capable to deal with :
  • 1. unsigned long and unsigned long long (sorry to ask again)
    2. Static arrays outside structures
    3. Multi-dimensions static arrays inside and outside structures
    4. The possibility initialize static arrays like : ArrayName.f[4] = {0.0, 1.0, 2.0, 3.0}
    5. The ternary operator
Will all this be introduced into the PureBasic language :?:

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
Keya
Addict
Addict
Posts: 1864
Joined: Thu Jun 04, 2015 7:10 am

Re: Blog post !

Post by Keya »

bitfields please :P
User avatar
STARGÅTE
Addict
Addict
Posts: 1562
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Blog post !

Post by STARGÅTE »

Just because a C-compiler is used in the backend does not mean that the C-syntax is adopted into PB! Of course not!
All items you listed are feature request for the PureBasic syntax but they are not directly correlated to the compiler backend change.
PB 5.73 ― Win 10, 20H2 ― Ryzen 9 3900X ― Radeon RX 5600 XT ITX ― Vivaldi 4.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
Josh
Addict
Addict
Posts: 1184
Joined: Sat Feb 13, 2010 3:45 pm

Re: Blog post !

Post by Josh »

StarBootics wrote:Will all this be introduced into the PureBasic language :?:
Stay cool and wait and see. The first goal should be that Pb under C runs as stable as it does now with the current language set.
sorry for my bad english
User avatar
skywalk
Addict
Addict
Posts: 3532
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Blog post !

Post by skywalk »

I too remain cool, but want to see the ;;'s dropped from this list?

Code: Select all

  ;          ; Type,   Bytes,  Min,                     Max,                     C Type
  ;;ul.ul[0] ; ULong,      4,  0,                       4294967295,              unsigned long, unsigned int, DWORD(C++)
  ;;uq.uq[0] ; UQuad,      8,  0,                       18446744073709551615,    unsigned long long, ULONGLONG
  ;;ld.ld[0] ; LDouble,   10,                -3.4e-4932,               1.1e+4932,long double(19 decimal places)

Code: Select all

; #PB_Compiler_Unicode = 1 (PB v5.4+ dropped Ascii compiles)
Structure ScanAllTypes  ;-!PB Datatypes
  ; Allows 1 Define for all datatypes to be scanned.
  ; Define *p.ScanAllTypes = @somevariable or *somememory
  ; Consider as a StructureUnion. Takes no memory and overflow is not checked.
  ; Ex. *p\d[i] ; 'i' can be incremented in a loop without compiler error.
  ;          ; Type,   Bytes,  Min,                     Max,                     C Type
  b.b[0]     ; Byte,       1, -128,                     127,                     char, bool(C++)
  a.a[0]     ; Ascii,      1,  0,                       255,                     unsigned char, UCHAR, BYTE
  c.c[0]     ; Character,  2,  0,                       65535,                   unsigned short, USHORT
  u.u[0]     ; Unicode,    2,  0,                       65535,                   unsigned short, USHORT
  w.w[0]     ; Word,       2, -32768,                   32767,                   short, VB6 integer
  l.l[0]     ; Long,       4, -2147483648,              2147483647,              long, int (long & $FFFFFFFF = unsigned)
  ;;ul.ul[0] ; ULong,      4,  0,                       4294967295,              unsigned long, unsigned int, DWORD(C++)
  i.i[0]     ; Integer,    4, -2147483648,              2147483647,              long, int(x86 or 32-bit),sizeof*
  ;i.i[0]    ; Integer,    8, -9223372036854775808,     9223372036854775807,     long long(x64 or 64-bit),sizeof*
  q.q[0]     ; Quad,       8, -9223372036854775808,     9223372036854775807,     long long
  ;;uq.uq[0] ; UQuad,      8,  0,                       18446744073709551615,    unsigned long long, ULONGLONG
  f.f[0]     ; Float,      4,           -1.175494e-38,            3.402823e+38,  float      (6 decimal places)
  d.d[0]     ; Double,     8, -2.2250738585072013e-308, 1.7976931348623157e+308, double     (15 decimal places)
  ;;ld.ld[0] ; LDouble,   10,                -3.4e-4932,               1.1e+4932,long double(19 decimal places)
  ;;s.s      ; String$,    2/char + 2 for chr(0),       ,                        wchar_t, TCHAR
  ;s.s[0]    ; FAIL, -> *p = @x$, *p\s[0] = IMA ERROR.
  s.s{1}[0]  ; {FixedLen}, 2/char,                      ,                        char *, char var[] <-- Convert to Ascii
  ss.s[0]    ; Scan String array.
  ;s.s[0]    ; FAIL, -> *p = @x$(), *p\s[1],  *p\s[2],  etc.
  ;s.s[0]    ; OK,   -> *p = @x$,   *p\s[1],  *p\s[2],  etc.
  ;ss.s[0]   ; OK,   -> *p = @x$(), *p\ss[1], *p\ss[2], etc.
EndStructure
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
kenmo
Addict
Addict
Posts: 1897
Joined: Tue Dec 23, 2003 3:54 am

Re: Blog post !

Post by kenmo »

STARGÅTE wrote:Just because a C-compiler is used in the backend does not mean that the C-syntax is adopted into PB! Of course not!
All items you listed are feature request for the PureBasic syntax but they are not directly correlated to the compiler backend change.
100% correct STARGATE.

Also Fred said there is no plan to deprecate the Assembly backend... so let's not expect a rush of new C-based features yet! :)

Hopefully requested bugfixes do not get neglected during work on the C backend, though.



Anyway, for feature requests, +1 for Danilo's procedure-via-structure request :!:
User avatar
StarBootics
Enthusiast
Enthusiast
Posts: 695
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Blog post !

Post by StarBootics »

STARGÅTE wrote:Just because a C-compiler is used in the backend does not mean that the C-syntax is adopted into PB! Of course not!
All items you listed are feature request for the PureBasic syntax but they are not directly correlated to the compiler backend change.
It's me or you are little bit rough, it's probably me ...

I'm aware that the C syntax will not be adopted directly into PureBasic. That being said it should be fairly easy to make the feature request I have listed into the PureBasic syntax because GCC already know how to deal with that stuff.

Anyway, the question I have asked was meant to be answered by Fred and/or Freak only.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
kenmo
Addict
Addict
Posts: 1897
Joined: Tue Dec 23, 2003 3:54 am

Re: Blog post !

Post by kenmo »

I think it was just emphasis, I don't think he was being rough :)
User avatar
useful
Enthusiast
Enthusiast
Posts: 270
Joined: Fri Jul 19, 2013 7:36 am
Location: Novosibirsk

Re: Blog post !

Post by useful »

Very interested in the answer to an important question.
It is especially important for the linux ecosystem.
Will it be possible to outsource the generated C source to be built with gcc without purebasic?
p.s. I mean the ability to generate standalone deb-src (rpms)
deeproot
Enthusiast
Enthusiast
Posts: 217
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: Blog post !

Post by deeproot »

Wow! - this is a busy thread :mrgreen: Thought I might join the party with my simple response :
Josh wrote:Stay cool and wait and see. The first goal should be that Pb under C runs as stable as it does now with the current language set.
+1 ... that will do nicely for me :)

Exciting stuff but very happy to wait until Fred and the team have done their magic. The current PureBasic is already great as it is - if a new back-end helps with future versions and platforms then that's fantastic.
kenmo wrote:I think everyone should relax :D

Fred & team know PureBasic internals better than all of us. They know the pros and cons of what they're doing, and I'm sure they'll make it as backwards-compatible as possible. Also, it's the PB team... you know they love simplified toolchains and fast write-and-run cycles!

It's newly announced, and some people are already asking for specific C output for PB input snippets?! Too soon :)
... Exactly!!
User avatar
Keya
Addict
Addict
Posts: 1864
Joined: Thu Jun 04, 2015 7:10 am

Re: Blog post !

Post by Keya »

I will relax while being excited
Axolotl
Enthusiast
Enthusiast
Posts: 116
Joined: Wed Dec 31, 2008 3:36 pm

Re: Blog post !

Post by Axolotl »

Hi folks,

as written before: I love reading this thread. It just shows how active this community is -- and that we care what happens to PB.
I think the first goal is to get an almost equal exchange of the compiler. If that's all okay, there will (maybe) be improvements in any direction. But we all don't know that. As the discussion shows, the ideas about improvements are also far apart.
Let's see which of the various ideas will find favor with the development team.

In any case, i'm relaxed and looking forward to testing the first beta.
Happy Coding and stay healthy.
Mostly running PureBasic <latest stable version and current alpha/beta> (x64) on Windows 10 Home
Post Reply