SubFunctions
#1
Posted 08 September 2005 - 02:22 PM
Func a()
Func b()
EndFunc
EndFunc
I'd assume that would work but it doesn't. Please point out how to impliment subfunctions.
#2
Posted 08 September 2005 - 02:25 PM
a() b() c() Func a() ; do some code here EndFunc Func b() ; do some other code here EndFunc Func c() a() b() EndFunc
Edited by gafrost, 08 September 2005 - 02:26 PM.
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
#3
Posted 08 September 2005 - 02:27 PM
Yes this is what I've been doing however a and b are NOT subfunctions, they are just other functions! See here: http://www.gentee.com/doc/syntax/subfunc.htma() b() c() Func a() ; do some code here EndFunc Func b() ; do some other code here EndFunc Func c() a() b() EndFunc
How can I impliment a true subfuntion..?
#4
Posted 08 September 2005 - 02:29 PM
#5
Posted 08 September 2005 - 02:31 PM
#6
Posted 08 September 2005 - 02:31 PM
for example
a(0) b(1) Func a($i_var) if $i_var then return 1 endif return 0 EndFunc Func b($i_var) if $i_var then c() Endif EndFunc Func c() ; do some code here EndFunc
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
#7
Posted 08 September 2005 - 02:36 PM
far as I know not in this scripting language
Okay well this is my idea, impliment real subfunctions.
Func a()
Func b()
EndFunc
EndFunc
Is way better than being forced into using:
Func a()
b()
EndFunc
Func b()
EndFunc
See the link in my second post for a detailed explination on subfunctions and why using a standard function just is not the same! I am baffeled as to why AutoIt does not have such a simple feature that is so important to a scripting language.
#8
Posted 08 September 2005 - 02:38 PM
Func a()
Func b()
EndFunc
EndFunc
Brings only confusion to the code. makes it hard to read...
#9
Posted 08 September 2005 - 02:43 PM
All major languages have this essential feature, read the link I posted for insight into why. I don't understand why AutoIt doesn't include it. I would assume the target audience is a bit too low to understand it.In my eyes
Func a()
Func b()
EndFunc
EndFunc
Brings only confusion to the code. makes it hard to read...
#10
Posted 08 September 2005 - 02:57 PM
Maybe...All major languages have this essential feature, read the link I posted for insight into why. I don't understand why AutoIt doesn't include it. I would assume the target audience is a bit too low to understand it.
#11
Posted 08 September 2005 - 03:13 PM
All major languages you say? Hmm, off the top of my head, C, C++, C# don't and I don't think Java does either. Right now those are the primary development languages in the world and none of them do so please stop over-exaggerating the ubiquity of the feature.All major languages have this essential feature, read the link I posted for insight into why. I don't understand why AutoIt doesn't include it. I would assume the target audience is a bit too low to understand it.
I've also stated already that it probably won't be implemented. There is no overwhelming reason. Yes, in some cases it may make code more modular and easier to read since all related code is located under a common item. But there is no real great need for the feature. It doesn't offer tremendous benefits and just adds unnecessary complexity. A function is a function no matter what scope is at and so long as the function can be seen where it needs to be used (Not a problem in AutoIt) then it doesn't matter if that function is at the global scope or local scope. Since it's not possible to implement at the local scope, the global scope will have to serve you.
Also I will point out that the example you link to is horrid. If you want a mini-global scope to use like that, then use a global variable with a highly unique name. The usefulness of sub-functions doesn't stem from them having access to local variables but rather from having functions scoped to where they are used. People should never write code as shown in that example because it's just as bad as using global variables judiciously. It makes the code hard to read and hard to follow.
The ideal usage I've seen for sub-functions is similar to below:
func DoSomething(array theArray) { sub-function UseElement(array_item theItem) { theItem += 250; theItem &= 0xFFFF // Bitwise and print(theItem) } for (i = 0; i < theArray.Size(); ++i) { UseElement(theArray[i]) theArray[i] += random(1000, 9999) UseElement(theArray[i]) } }
#12
Posted 08 September 2005 - 03:52 PM
Which major languages support this? Pascal is the only one I know of that does and that feature is not used that often. C, C++, Java, Visual Basic, Perl, AWK, javascript, vbscript, Fortran, Ada, Cobol, AutoIt, etc. do not support nesting function definitions (which is what this feature is usually called). In any language that supports user-defined functions and procedures, including AutoIt, any function can be called from within another function, even recursively (calling a function from within itself), but this is not the same as what you are asking for.All major languages have this essential feature, read the link I posted for insight into why. I don't understand why AutoIt doesn't include it. I would assume the target audience is a bit too low to understand it.
The only reason I can think of to use a feature like this is to hide a function from calls by outside functions. Most of these languages have features to promote that, although AutoIt does not. Any function can be called from any other place, without restriction.
I would hardly call this an essential feature. A confusing one, sure, but actually not that useful.
#13
Posted 08 September 2005 - 05:11 PM
actually PERL does support a similar feature. It's called private function and it is only available inside the scope where it was defined.Which major languages support this? Pascal is the only one I know of that does and that feature is not used that often. C, C++, Java, Visual Basic, Perl, AWK, javascript, vbscript, Fortran, Ada, Cobol, AutoIt, etc. do not support nesting function definitions (which is what this feature is usually called). In any language that supports
For the rest, I agree with you.
$retval = Calc(5,5); print("value = $retval\n"); sub Calc { my ($first, $second) = @_; my $square = sub { return($_[0] ** 2); }; return(&$square($first) + &$square($second)); };
PS: Don't be afraid of my post number (666)
Cheers
Kurt
Edited by /dev/null, 08 September 2005 - 05:12 PM.
#14
Posted 08 September 2005 - 07:03 PM
I have taught myself Perl from example scripts and help files and have never used that feature. I still do not think I would use it that often.actually PERL does support a similar feature. It's called private function and it is only available inside the scope where it was defined.
For the rest, I agree with you.
Cheers
Kurt
#15
Posted 08 September 2005 - 07:26 PM
You're right, that feature ist rarely used and not well known either. But as you know, there are many ways to solve a problem in Perl.....I have taught myself Perl from example scripts and help files and have never used that feature. I still do not think I would use it that often.
Cheers
Kurt
#16
Posted 09 September 2005 - 04:14 PM
.NetAll major languages you say? Hmm, off the top of my head, C, C++, C# don't and I don't think Java does either. Right now those are the primary development languages in the world and none of them do so please stop over-exaggerating the ubiquity of the feature.
The feature is a bit too complex for someone like you to understand well, judging by your post. The target audience can't figure out how to use a feature so lets not include it seems to be the mentality of AutoIt development. Anyway I'm moving back to a "real" language, thanks anyway!
#17
Posted 09 September 2005 - 05:36 PM
First of all, you are an idiot..Net
The feature is a bit too complex for someone like you to understand well, judging by your post. The target audience can't figure out how to use a feature so lets not include it seems to be the mentality of AutoIt development. Anyway I'm moving back to a "real" language, thanks anyway!
Second, .NET is currently comprised of C++ .NET, C# and VB .NET off the top of my head. The last time I looked, none of those languages supported "sub-functions" so why you mention .NET is beyond me. I'm being generous here, too, and ignoring the fact that .NET is not a language itself but rather a framework.
Third, I fully understand sub-functions, probably better than you do. I've used them in other languages (Lua comes to mind where I use them extensively). So please don't assume that because you are a dumbass that I don't fully comprehend a feature.
Forth, you're an idiot. Wait, I covered that? Well, how about this then. See that little bit next to my name and Nutster's name? See how it says "Developers"? David (Nutster) and I both pretty much iterated the exact same thing in our posts. Quite obviously, we are two of several people who could make your feature happen but we both shot it down for the same reasons without any prior correspondence on the matter. In other words, we didn't mean to say the same thing, but we're both well aware enough of what you ask for to see the same problems in it. So I don't think insulting our intelligence and telling us how to do things is the best way to ever get anything done.
And last, I will show a rare emotion and admit that I feel sorry for whatever community that you find that coincides with your "real" language. You've obviously not got any substance to contribute and while I do relish in the fact that you will be departing so soon after arriving, I do lament in the pain you will inflict to others with your supreme idiocy.
And with that this post has gone full circle so I bid you adieu.
#18
Posted 09 September 2005 - 08:47 PM
Edited by tylo, 09 September 2005 - 08:50 PM.
#19
Posted 09 September 2005 - 09:38 PM
It allows you to create a function within a function, but the behaviour is weird.
This is right out of their documentation:
<?php function foo() { function bar() { echo "I don't exist until foo() is called.\n"; } } /* We can't call bar() yet since it doesn't exist. */ foo(); /* Now we can call bar(), foo()'s processesing has made it accessible. */ bar(); ?>
#20
Posted 09 September 2005 - 10:51 PM
All major languages have this essential feature, read the link I posted for insight into why. I don't understand why AutoIt doesn't include it. I would assume the target audience is a bit too low to understand it.
Hey "buddy", we are still waiting for an explanation why sub functions are so essential! I really want to learn something. Please be my advisor!
Cheers
Kurt
Edited by /dev/null, 13 September 2005 - 12:06 AM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users



