Page 1 of 2

Optional Parameters Anywhere.

Posted: Sun Feb 19, 2006 8:36 pm
by Shannara
I think this is self-explainatory. But just in case ... If we can have these, then we can group the parameters in logical order instead of shoving all optionals at the end.

Posted: Sun Feb 19, 2006 9:02 pm
by Trond
Image

Posted: Sun Feb 19, 2006 9:03 pm
by blueznl
i guess, trond, he means

x( a , , b , c )

so you could skip one...

Posted: Sun Feb 19, 2006 9:24 pm
by Trond
Oh, I thought he meant:
x( a, b, c ) ; Now, which ones of the five optional parameters did we skip? How to do type checking for this, it will be a lot of work.

Posted: Sun Feb 19, 2006 9:59 pm
by Thomas
For example the positional parameters for ResizeWindow() if you really just want to resize and not move the window. :?

Posted: Mon Feb 20, 2006 12:52 am
by Shannara
Blueznl has it on the dot.

Posted: Mon Feb 20, 2006 1:02 am
by Intrigued
I wondered on this before myself. #PB_NoChange?

;)

Posted: Mon Feb 20, 2006 1:43 am
by Dare2
I also thought that the first post meant put any parameter anywhere ... sorry Shannara. It is silly season on the boards these last 24 hours.

The idea of "empty" parameters (a,,c) is neat. An implied "No Change" or "Use Default" or whatever.

Posted: Mon Feb 20, 2006 8:26 am
by blueznl
i think it's not possible though :-) as all par's are (i assume) pushed on the stack, you can't push nothing on the stack, and you can't push an identifier on the stack as it may have the same value as the identifier

so i think i can predict fred's answer, and i guess it's the right one too: no :-)

Posted: Mon Feb 20, 2006 12:41 pm
by Dare2
Hmmm.

Hopefully with:

Code: Select all

Procedure myProc( myPar.l = 0, myOther.l = -1, myNext,l = 10)
  ; stuff
EndProcedure
The compiler alread knows what is required when it reaches:

Code: Select all

myProc(1,,2)
So, push comes to shove, it can load the stack with:
  • 1 (it was given)
    -1 (it is the known default)
    2 (it was given)
Cross fingers.

Edit:

Btw, Blueznl, would you object if this capability was made available?

Posted: Mon Feb 20, 2006 4:06 pm
by freak
Dare2 wrote:

Code: Select all

myProc(1,,2)
That just looks ugly :P

Posted: Mon Feb 20, 2006 4:56 pm
by blueznl
well, ugly or not, i dunno :-)

filling in anything makes it not usefull to have optional parameters :-)

but finally, i am not the one to object anything, i'm just a user! :-)

Posted: Mon Feb 20, 2006 4:59 pm
by Kale
I'm sure i read somewere that optional parameters have got to be at the end of the parameter list. I don't fully understand why but it's got something to do with the internals of how PB calls procedures.

Posted: Mon Feb 20, 2006 5:01 pm
by blueznl
Kale wrote:I'm sure i read somewere that optional parameters have got to be at the end of the parameter list. I don't fully understand why but it's got something to do with the internals of how PB calls procedures.
i do suspect so as well, yes :-) but hey, i'm pretty happy we do have this feature, so don't mind!

Posted: Mon Feb 20, 2006 6:57 pm
by Fred
freak wrote:
Dare2 wrote:

Code: Select all

myProc(1,,2)
That just looks ugly :P
+1 ;)