Page 13 of 22

Re: Blog post !

Posted: Fri Mar 19, 2021 5:59 pm
by skywalk
Agreed.
Break n is concise and to the point.
Refactoring nested For Loops with complex conditionals is a nightmare.

Re: Blog post !

Posted: Fri Mar 19, 2021 6:41 pm
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.

Re: Blog post !

Posted: Fri Mar 19, 2021 8:32 pm
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.

Re: Blog post !

Posted: Fri Mar 19, 2021 8:39 pm
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

Re: Blog post !

Posted: Fri Mar 19, 2021 9:19 pm
by Keya
bitfields please :P

Re: Blog post !

Posted: Fri Mar 19, 2021 9:23 pm
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.

Re: Blog post !

Posted: Fri Mar 19, 2021 9:25 pm
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.

Re: Blog post !

Posted: Fri Mar 19, 2021 11:18 pm
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

Re: Blog post !

Posted: Fri Mar 19, 2021 11:39 pm
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 :!:

Re: Blog post !

Posted: Sat Mar 20, 2021 2:33 am
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

Re: Blog post !

Posted: Sat Mar 20, 2021 4:19 am
by kenmo
I think it was just emphasis, I don't think he was being rough :)

Re: Blog post !

Posted: Sun Mar 21, 2021 2:28 am
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)

Re: Blog post !

Posted: Sun Mar 21, 2021 11:39 am
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!!

Re: Blog post !

Posted: Sun Mar 21, 2021 12:18 pm
by Keya
I will relax while being excited

Re: Blog post !

Posted: Sun Mar 21, 2021 3:39 pm
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.