• Welcome to Jose's Read Only Forum 2023.
 

PureBasic and GOSUB

Started by Theo Gottwald, October 21, 2013, 07:55:45 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge


With an inner gosub, there is always a risk of inadvertently falling into the body of the subroutine, but apart from that, the integrity of the stack would not be too hard to maintain.

Patrice Terrier

Really i couldn't figure how, for a SDK programmer, PowerBASIC could be easier to translate to PureBasic rather than  C++, i would like to understand that, because i have not attirance for sadomaso.  8)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Jim Dunn

Quote... The last two versions of (PowerBASIC) saw significant bloat added ...

I'm not sure "significant" is the right word here; what's a few bytes/kilobytes/megabytes in this day/age.

Theo Gottwald

Patrice, its C that looks so far from Basic to me. But this is personal taste.
PureBasic also has the advantage that you can write a mail to the lead programmer (Fred) and he WILL give you an answer that helps. I like his behavior.

Brice Manuel

Quote from: Jim Dunn on October 22, 2013, 03:22:38 PM
I'm not sure "significant" is the right word here; what's a few bytes/kilobytes/megabytes in this day/age.

"Bloat because you can" is a lazy and shoddy programming methodology.

Patrice Terrier

Quoteits C that looks so far from Basic to me
Not, when you are using the SDK coding style, they are exactly the same!
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Theo Gottwald

#21
Structurally, not exactly, Patrice  :D

Patrice Terrier

#22
Structurally, a basic "Hello world" window, with a winproc callback and a message pump are exactly the same really.   :)
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Theo Gottwald

Quote from: Patrice Terrier on October 22, 2013, 09:20:20 PM
Structurally, a basic "Hello world" window, with a winproc callback and a message pump are exactly the same really.   :)

Yes, but later it looks like this:

; ListView.GetSubItemRect((INT) pHeader->nmcd.dwItemSpec, pHeader->iSubItem, LVIR_BOUNDS, &Position);
::)

and ... does it have a GOSUB?

Charles Pegge


GCC supports nested functions, with access to parent variables, a perfect substitute for gosub:


  #include <stdio.h>

  int main()
  {
    int a;
    void mygosub()
    {
     a=42;
    }
    mygosub();
    printf("%i",a); // 42
  }

James C. Fuller

Charles,
  Not my gcc

Quote
C:\CodeBlocks\Projects\nestes02\main.c|8|warning: ISO C forbids nested functions [-Wpedantic]|

James

Charles Pegge

Hi James,
My rig is a console-and-notepad job:
I compile direct with no switches : gcc gosub.c
It compiles to a.exe which is convenient for testing

Theo Gottwald

Does it really compile to just 1 Mnemonic for CALL and one Mnemonic for RET?

James C. Fuller

Quote from: Charles Pegge on October 23, 2013, 01:30:24 PM
Hi James,
My rig is a console-and-notepad job:
I compile direct with no switches : gcc gosub.c
It compiles to a.exe which is convenient for testing

Charles,
  I did a quick compile with code::blocks where I had the iso standard flag set hence the warning
It is a  gcc feature.

James