Two ideas

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
pwong
New User
New User
Posts: 1
Joined: Sun Jan 23, 2005 7:51 pm

Two ideas

Post by pwong »

I am a novice. I have two ideas. Please don't laught at me if you think it's stupid.

1) Function that return multiple values. This may be convenient in some cases. It seems only Python allow returning values like this :
(varC, varD) = function()

2) Allow compiling with different mode, eg. fast/normal/debug. Where fast mode have least checking, debug mode have more checking. In other words, allow user to exclude some code fragments from compiling. And without hurting readability too much.

What do you think ?
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

1. Two values can be returned from procedures by using pointers.

Code: Select all

Procedure.l MakePoints(Value.l)
    Static Coords.POINT
    Coords\x = Value & $FFFF
    Coords\y = (Value >> 16) & $FFFF
    ProcedureReturn @Coords
EndProcedure

*Screen.POINT = MakePoints(67109632)

Debug *Screen\x
Debug *Screen\y 
2. You can specify certain sections of code to compile using the compiler directive '#CompilerIF'.

http://www.purearea.net/pb/english/manu ... tives.html

See the book in my signature for complete code examples and tutorials of such things. :wink:
--Kale

Image
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

note: PB is a Compiler, Phyton is an Interpreter.
some fast/slow options are Interpreter-specifications, it has nothing to do with compiling.
there are much more differences between Phyton and PB.

1) really complicated, since the return-value of a function is stored in a register.
return a pointer to a structure if you want more than one value to be returned.

2) > allow user to exclude some code fragments from compiling
see the Compiler Directives
oh... and have a nice day.
Post Reply