| View previous topic :: View next topic |
| Author |
Message |
Ian
Joined: 15 Jul 2007 Posts: 1077 Location: Enterprise, Alabama
|
Posted: Mon May 12, 2008 1:55 am Post subject: More Options in Function Parameters |
|
|
Something like this:
| Code: | | function(num x, alp y) |
Where num is a number and alp is an alpha char(s). _________________ 1,000 Posts achieved on Saturday April 26, 2008 1:45 am |
|
| Back to top |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 753 Location: London, UK
|
Posted: Mon May 12, 2008 1:57 am Post subject: |
|
|
Why???
What benefit would this have. Apart from limiting what is sent to the function, but then seeing as you are calling the function, its down to you to make sure you send the correct info. _________________ Steve F AKA Superfraggle
http://r.yuwie.com/superfraggle |
|
| Back to top |
|
 |
TheIrishThug
Joined: 19 Mar 2006 Posts: 347
|
Posted: Mon May 12, 2008 2:10 pm Post subject: |
|
|
If you are writing a library it may not be you who is calling the functions. It would allow AutoHotkey's internals to do some type checking and not force programmers to bog-down their functions with them.
Rule #1: Never trust user input. I try to do the same even when I'm likely to be the only person to use my code. |
|
| Back to top |
|
 |
jballi
Joined: 01 Oct 2005 Posts: 297 Location: Texas, USA
|
Posted: Mon May 12, 2008 8:46 pm Post subject: |
|
|
I find it very difficult to believe that I'm sticking my foot in this topic!
It appears that this "feature" has limited value unless you are able to (forced to?) assign a data type to all variables, not just function parameters. Without it, most errors would only be discovered at run-time.
Example: User enters '123' to a variable which is passed to function -- No problem. User enters 'ABC' to a variable which is passed to function -- Run-time 'Data type' failure!
Yes, the error message would improve debugging but the value is significantly diminished without a compile-time error.
Them be my thoughts... |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 2359 Location: Australia, Qld
|
Posted: Mon May 12, 2008 9:53 pm Post subject: |
|
|
| jballi wrote: | | Yes, the error message would improve debugging but the value is significantly diminished without a compile-time error. | I agree, especially since the same effect can be achieved with hardly any more code in each function:
| Code: | function(x, y) {
num(x), alp(y)
; or
test_params("num", x, "alp", y)
;...
} | Of course, someone would need to write the functions. Preferably someone that sees value in the idea... |
|
| Back to top |
|
 |
|