Page 1 of 1

Posted: Wed Apr 10, 2002 6:01 pm
by BackupUser
Restored from previous forum. Originally posted by DarkUni.

I've written Fred about this, but I'm curious about the group's thoughts on it.

When writing in PB, you are required to have PROCEDURES created in the code BEFORE its ever referenced - this requires a form of sequentiality that really bugs me.

Typically, when I code, I use this format:








The main loop is typically where I compile my collection of Function/Procedure calls. Functions/Procedures are typically added constantly throughout development, so it makes it easy to PAGE DOWN to the end, add a new Procedure, link it in the Main Loop.

In PB, however, Procedures are REQUIRED to come before ANY references to them (i.e. the Main Loop).

Now I'm not saying my way is the RIGHT way; however, it seems unnecessarily restrictive to REQUIRE the typically 'detattached' Procedure code to be present before its references to it.

I've looked at a lot of PB code, and it seems as is Procedures (by and large) and not very popular here (life's blood for me in Blitz - Everything is a function; and it drastically increases performance in game development - I learned the hard way). Perhaps this is the reason no one else speaks of this or it doesn't bother too many people because they just don't use them as a rule.

Anyway, that's my outlook. I was hoping this restriction would go away with 3.0, but its still there. It makes me porting games from Blitz that much more challenging - but I would like to.

Anyone in agreement, or am I just a dork? :)

Note: I'm not talking about referencing Procedures that DON'T EXIST yet - I'm talking about a procedure that is LOWER in the code listing than the reference:






In this sample, procedure 1 can be called from the Main Loop. Procedure 2 cannot be - even though they both exist and are functional.

Thanks guys!

Shane R. Monroe, Dark Unicorn Productions
Pure Basic Basement
http://pb.darkunicornproductions.com

Posted: Wed Apr 10, 2002 6:18 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.

It is indeed added in PB 3.0, check the history and also check this thread by Franco:
viewtopic.php?t=1066

Of course you have to change your prefered coding format from:

Code: Select all







to something like this:

Code: Select all








But i'm sure you'll survive that change :wink:



Edited by - Pupil on 10 April 2002 19:31:36

Posted: Wed Apr 10, 2002 6:36 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> Functions/Procedures are typically added constantly throughout development,
> so it makes it easy to PAGE DOWN to the end, add a new Procedure, link it in
> the Main Loop. In PB, however, Procedures are REQUIRED to come before ANY
> references to them (i.e. the Main Loop).

What I do is put all my procedures in a separate file, then 'IncludeFile' this at
the start of my main code. Then, every procedure can be used anywhere in my
main code, and new procedures are easily added to the external file at will.

But as Pupil said, a new 'Declare' command has been added to v3 to fix this, but
I still prefer my external file method.


PB - Registered PureBasic Coder

Edited by - PB on 10 April 2002 19:37:40

Posted: Wed Apr 10, 2002 7:08 pm
by BackupUser
Restored from previous forum. Originally posted by Franco.
What I do is put all my procedures in a separate file, then 'IncludeFile' this at
the start of my main code. Then, every procedure can be used anywhere in my
main code, and new procedures are easily added to the external file at will.
Yes PB this is my method too.
But It works only if YOU choose 'the right sequence' of procedures in your separate file (...if any procedure uses another procedure).

With the new Declare command you don't need to have 'a right sequence'.



Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Posted: Wed Apr 10, 2002 8:35 pm
by BackupUser
Restored from previous forum. Originally posted by DarkUni.

Thanks for the input guys ... I guess it is a start. I've never been a big fan of declarations (I'm lazy - does it show? :) but at least there is a workaround.

Now I just need to write a little parser that will let me take existing Blitz code, rip out a function list, and create a Declaration list to easily insert into PB.

Thanks again for the input and assistance!

I've never been a big fan of Includes ... too easy to botch something up for me. What I rather enjoyed was foldable functions/procedures in some other languages/editors. Shame I haven't seen an editor or language that supports it in YEARS.

Shane R. Monroe, Dark Unicorn Productions
Pure Basic Basement
http://pb.darkunicornproductions.com

Posted: Wed Apr 10, 2002 10:25 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
I've never been a big fan of Includes ... too easy to botch something up for me. What I rather enjoyed was foldable functions/procedures in some other languages/editors. Shame I haven't seen an editor or language that supports it in YEARS.
It's not really the language that needs to support folding though. You could quite easily get it done using just an editor, and stick the fold marks into the code as comments. Of course, some people might see it as "dirty" to have an editor add things to their code (e.g. a line before and after a procedure saying "; fold me here!"), but the PB compiler does that anyway, so they have no reason to complain :wink:


--
It's not minimalist - I'm increasing efficiency by reducing input effort.

Posted: Wed Apr 10, 2002 11:35 pm
by BackupUser
Restored from previous forum. Originally posted by fred.

Of course, some people might see it as "dirty" to have an editor add things to their code (e.g. a line before and after a procedure saying "; fold me here!"), but the PB compiler does that anyway, so they have no reason to complain :wink:
[/quote]

Just at the bottom of the file, to avoid an extra .prefs .

Fred - AlphaSND

Posted: Thu Apr 11, 2002 3:53 am
by BackupUser
Restored from previous forum. Originally posted by DarkUni.

Well, I was talking more about languages that didn't allow command line compiling (like Blitz). True, you can use any editor with PB, but the sad truth is, I haven't been able to find an editor that folds. Something I was HORRIBLY spoiled with in AMOS...

AMOS spoiled me really bad - quite a shame. Then having to deal with the Blitz Basic editor makes the PB editor look like UltraEdit Deluxe (heh). :)

Shane R. Monroe, Dark Unicorn Productions
Pure Basic Basement
http://pb.darkunicornproductions.com