Page 1 of 1

Two ideas

Posted: Wed Jan 17, 2007 8:24 am
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 ?

Posted: Wed Jan 17, 2007 9:18 am
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:

Posted: Wed Jan 17, 2007 9:19 am
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