Page 1 of 1

improve Procedures

Posted: Thu Dec 14, 2006 6:06 pm
by Darie
At first, i adore the new PureBasic Version !!! Pure Basic is getting better...
But I'd like to suggest something:

It should be possible to define procedures within procedures (like you can do with turbo pascal or delphi) and it should be possible to pass completed structures, arrays or LinkedLists as parameters and also return them back completely with the ProcedureReturn-Command.

I think, this would improve much structured programming, because you can write "self-contained" procedures and use them like methods for structures etc.

Posted: Thu Dec 14, 2006 6:45 pm
by Nik
Doesn't sound very Pure to me and i think it somehow contardicts to the fact that pureBasic is very C like. In my opinion the only thing we can do very easily whcih would improve Code structure a lot would be namespaces as in C++

Posted: Thu Dec 14, 2006 6:48 pm
by Trond
> Doesn't sound very Pure to me and i think it somehow contardicts to the fact that pureBasic is very C like.
Which in fact lets you return a structure...

Re: improve Procedures

Posted: Thu Dec 14, 2006 7:12 pm
by Kale
Darie wrote:At first, i adore the new PureBasic Version !!! Pure Basic is getting better...
But I'd like to suggest something:

It should be possible to define procedures within procedures (like you can do with turbo pascal or delphi) and it should be possible to pass completed structures, arrays or LinkedLists as parameters and also return them back completely with the ProcedureReturn-Command.

I think, this would improve much structured programming, because you can write "self-contained" procedures and use them like methods for structures etc.
The procedure within a procedure is not possible with PB but everything else is. Arrays and Linked lists are passed by reference. meaning that when manipulated within a procedure you are really manipulating the original that was passed as a parameter. Structured vars can be returned as a pointer, which can be accessed using a structured pointer variable.

Search the forum there are loads of examples:
http://www.purebasic.fr/english/viewtopic.php?t=14737
http://www.purebasic.fr/english/viewtopic.php?t=21644
http://www.purebasic.fr/english/viewtopic.php?t=13363

Posted: Thu Dec 14, 2006 7:22 pm
by Darie
Isn't Fred trying to include OOP-Coding to pureBasic?

Have a look here -->
http://drac.site.chez-alice.fr/Tutorial ... en.htm#POO

It's possible to code OOP in PureBasic but it's a little bit confusing, don't you agree?

I think, making it possible to return everykind of datatypes in a procedure would make it much easier to code OOPlike programs.
You would be able to create LinkedLists or Arrays containing the Object-Datas (e.g. with structures) and use the procedures as methods.