Author Topic: PureBasic and GOSUB  (Read 13445 times)

0 Members and 1 Guest are viewing this topic.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 677
  • User-Rate: +27/-1
    • Charles Pegge
Re: PureBasic and GOSUB
« Reply #15 on: October 22, 2013, 01:19:38 PM »

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.

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: PureBasic and GOSUB
« Reply #16 on: October 22, 2013, 03:15:39 PM »
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

Offline Jim Dunn

  • Newbie
  • *
  • Posts: 36
  • User-Rate: +4/-0
Re: PureBasic and GOSUB
« Reply #17 on: October 22, 2013, 03:22:38 PM »
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.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
Re: PureBasic and GOSUB
« Reply #18 on: October 22, 2013, 04:05:27 PM »
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.

Offline Brice Manuel

  • Full Member
  • ***
  • Posts: 154
  • User-Rate: +0/-0
Re: PureBasic and GOSUB
« Reply #19 on: October 22, 2013, 04:27:11 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.

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: PureBasic and GOSUB
« Reply #20 on: October 22, 2013, 04:39:30 PM »
Quote
its 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

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
Re: PureBasic and GOSUB
« Reply #21 on: October 22, 2013, 09:01:11 PM »
Structurally, not exactly, Patrice  :D
« Last Edit: October 22, 2013, 09:21:44 PM by Patrice Terrier »

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: PureBasic and GOSUB
« Reply #22 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.   :)
« Last Edit: October 22, 2013, 09:23:59 PM by Patrice Terrier »
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
Re: PureBasic and GOSUB
« Reply #23 on: October 23, 2013, 10:12:01 AM »
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:

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

and ... does it have a GOSUB?

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 677
  • User-Rate: +27/-1
    • Charles Pegge
Re: PureBasic and GOSUB
« Reply #24 on: October 23, 2013, 10:40:35 AM »

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

Code: [Select]
  #include <stdio.h>

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

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: PureBasic and GOSUB
« Reply #25 on: October 23, 2013, 12:10:18 PM »
Charles,
  Not my gcc

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

James

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 677
  • User-Rate: +27/-1
    • Charles Pegge
Re: PureBasic and GOSUB
« Reply #26 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

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 935
  • User-Rate: +30/-4
    • it-berater
Re: PureBasic and GOSUB
« Reply #27 on: October 23, 2013, 03:08:49 PM »
Does it really compile to just 1 Mnemonic for CALL and one Mnemonic for RET?

Offline James C. Fuller

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 595
  • User-Rate: +11/-8
Re: PureBasic and GOSUB
« Reply #28 on: October 24, 2013, 03:50:35 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