Procedure's default argument bypass Request

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: Procedure's default argument bypass Request

Post by Joakim Christiansen »

Danilo wrote:Empty expressions would be the same:

Code: Select all

Ax(100,200, , , , ,4)
Ax(100,200,,,,,4)
+2 to this feature!
I like logic, hence I dislike humans but love computers.
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: Procedure's default argument bypass Request

Post by MachineCode »

+3 for empty params ("first,,,,fifth"). That's how Commodore BASIC did it, which I grew up with. :)
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
moogle
Enthusiast
Enthusiast
Posts: 372
Joined: Tue Feb 14, 2006 9:27 pm
Location: London, UK

Re: Procedure's default argument bypass Request

Post by moogle »

+1, been using this in VBA for a while.
Image
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Procedure's default argument bypass Request

Post by Shield »

I'd be in favor of named parameters as it's just more clear.

(Actually I'm in favor of being able to overload procedures, but I'm pretty sure we won't get that
at least for a very long time, so... :wink: )
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: Procedure's default argument bypass Request

Post by BorisTheOld »

Shield wrote:I'd be in favor of named parameters as it's just more clear.
I agree. And as you say, it's a good way to simulate overloading.

Statements such as:

Code: Select all

Result = Format(Integer=x, Mask=y)
Result = Format(Double=x, Mask=y)
are much easier to read, and less prone to error, than:

Code: Select all

Result = Format(,,,,,,x,,,,,,y)
Result = Format(,,,,,x,,,,,,,y)
Something to remember is that blank or missing operands can create problems if passed by value, since it's impossible to tell the true meaning of a value. Is it the value of the operand, or is it a marker to show that the operand is blank? Operands passed by reference are easier to manage, since a zero address indicates the absence of a value.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
ozzie
Enthusiast
Enthusiast
Posts: 443
Joined: Sun Apr 06, 2008 12:54 pm
Location: Brisbane, Qld, Australia
Contact:

Re: Procedure's default argument bypass Request

Post by ozzie »

BorisTheOld wrote:Something to remember is that blank or missing operands can create problems if passed by value, since it's impossible to tell the true meaning of a value. Is it the value of the operand, or is it a marker to show that the operand is blank? Operands passed by reference are easier to manage, since a zero address indicates the absence of a value.
"Blank or missing operands" should not be a problem, because parameters may only be omitted if they have a default value in the Procedure definition. That is the way it has been in VB6 for years and works well. However, having said that I'm certainly in favor of named parameters - which is a feature VB6 doesn't have!
User avatar
charvista
Addict
Addict
Posts: 949
Joined: Tue Sep 23, 2008 11:38 pm
Location: Belgium

Re: Procedure's default argument bypass Request

Post by charvista »

And I prefer the use of asterisks, as showed at the top of this thread.
After all, Fred will decide, if ever this feature will be implemented. If both asterisks/blanks and named variables are going to be implemented, then everybody will be happy :wink:
- Windows 11 Home 64-bit
- PureBasic 6.10 LTS (x64)
- 64 Gb RAM
- 13th Gen Intel(R) Core(TM) i9-13900K 3.00 GHz
- 5K monitor with DPI @ 200%
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Re: Procedure's default argument bypass Request

Post by gnasen »

I stumbled upon this different times. If I only want to set one of the last optional parameters, I have to look up all standard settings of the parameters before this one. It would make things a lot easier!
pb 5.11
Post Reply