Jump to content



Photo

SubFunctions


  • Please log in to reply
34 replies to this topic

#21 LxP

LxP

    Real satisfaction in every glass.

  • Active Members
  • PipPipPipPipPipPip
  • 1,619 posts

Posted 10 September 2005 - 01:19 AM

PHP kind of supports them...
It allows you to create a function within a function, but the behaviour is weird.

<{POST_SNAPBACK}>

To add to Saunders' info, because the bar() function sticks around outside the foo() call, you'll get an error that bar() is already defined if you subsequently call foo() again. This makes PHP's implementation of 'subfunctions' a rather useless one for anything other than a dodgy way to '#include'.

P.S. --

I would assume the target audience is a bit too low to understand it.

<{POST_SNAPBACK}>

How delightfully condescending. I'd like to suggest that perhaps the original poster does not fully understand the concept if s/he unjokingly believes it to be a 'necessary' feature of any language.

Edited by LxP, 10 September 2005 - 01:25 AM.








#22 Manus-Magnus

Manus-Magnus

    Wayfarer

  • Active Members
  • Pip
  • 57 posts

Posted 10 September 2005 - 02:16 AM

func afunc()
do
until
func apart()
if
endif
endfunc
endfunc



Only good point i see here is to be able to reduce source coude size in cases you got large functions and sometimes need to execute only a part of them. but this seems dangerous:
- not declared vars
- unreadable when code become larger
- how about a nice goto/label ? ;)

#23 MrSpacely

MrSpacely

    Polymath

  • Active Members
  • PipPipPipPip
  • 211 posts

Posted 13 September 2005 - 10:25 AM

Indeed why would you ever use subfunctions. It seems to be totally useless making script unreadable.
Please explain what would be the advantage.

Its more logical to call a function from a function the function is easier to read and easier to change a bug in a function you could just change that function.

Also you can re use any function. If you donot use subfunctions.
Also donot insult my intelligence please just explain why you think its usefull.

Donot say I would not understand just try if you are so good you can also explain.

And please short no novels

Edited by MrSpacely, 13 September 2005 - 10:30 AM.


#24 jefhal

jefhal

    Not The Appeaser

  • Active Members
  • PipPipPipPipPipPip
  • 708 posts

Posted 13 September 2005 - 11:54 AM

Indeed why would you ever use subfunctions.

How about a sub-function that does this?:

click on username: "Idea"
click on hyperlink: "Ignore User"
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

#25 Idea

Idea

    Wayfarer

  • Active Members
  • Pip
  • 59 posts

Posted 14 September 2005 - 04:25 PM

I'm nearly finished adding subfunctions as my project can't language switch due to budget issues. The community doesn't want subfunctions anyway. Delete this topic please!

If you want something done right do it yourself.

#26 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 14 September 2005 - 04:59 PM

I'm nearly finished adding subfunctions as my project can't language switch due to budget issues.

So it's more budget savvy to waste time adding a virtually useless features than it is to learn how to write proper code with the tools available? Please state your company so I know to never invoke their services; they obviously can't hire rational intelligent beings.

The community doesn't want subfunctions anyway.

Correct. This feature is not necessary and no need has ever arisen for it in the last two and a half years.

Delete this topic please!

I prefer it not deleted; it's a prime example of how not to make a feature demand. It's also a prime example of how to be a dumb ass, so all those out there reading this who want to grow up and be one, this thread is a good primer.

If you want something done right do it yourself.

Given that you feel this is such a critical feature and obstinately refuse to listen to the creators of the language, I hate to see whatever bastardized version of "right" you conjure up. I also question just how "right" somebody can do something when they insist that a unimportant feature is fundamental. If you haven't enough working brain cells to figure out how to write code without unnecessary features, how can anybody expect you to do something "right" at all?

I suppose next you'll be bitching about a lack of GoTo?

#27 Idea

Idea

    Wayfarer

  • Active Members
  • Pip
  • 59 posts

Posted 14 September 2005 - 05:08 PM

I suppose next you'll be bitching about a lack of GoTo?

<{POST_SNAPBACK}>

I've already implimented a limited form of GoTo similar to how Java does it. Don't let that hold you back from crippeling the language further though.

#28 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 14 September 2005 - 05:20 PM

As I requested, please state your company so I know to avoid them. I would also like it if you cited your source(s) for learning programming as I would also like to avoid those, too. Anybody advocating the use of "goto" in any functional language is a horrible programmer and should be promptly taken out into a field and shot. Their code should also be destroyed and perhaps even burning the hard drives the code was stored on might atone for such foolishness.

#29 /dev/null

/dev/null

    Universalist

  • MVPs
  • 2,946 posts

Posted 14 September 2005 - 06:05 PM

I'm nearly finished adding subfunctions as my project can't language switch due to budget issues. The community doesn't want subfunctions anyway. Delete this topic please!


So, you "added" subfunctions to exactly what??

If you want something done right do it yourself.


Sure, I guess that's why you asked to fix the spelling errors in your code, right???

Kurt

Edited by /dev/null, 14 September 2005 - 06:05 PM.

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

#30 jefhal

jefhal

    Not The Appeaser

  • Active Members
  • PipPipPipPipPipPip
  • 708 posts

Posted 14 September 2005 - 06:23 PM

So, you "added" subfunctions to exactly what??

His assembler code...
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

#31 Idea

Idea

    Wayfarer

  • Active Members
  • Pip
  • 59 posts

Posted 14 September 2005 - 06:52 PM

Sure, I guess that's why you asked to fix the spelling errors in your code, right???

Kurt

<{POST_SNAPBACK}>

Cute but no, the code in question required a rewright as the logic was wrong. The spelling errors were a result of removing information prior to posting, they never existed in the actual code. Thanks for your concern though.

#32 yutt

yutt

    Seeker

  • Active Members
  • 38 posts

Posted 14 September 2005 - 09:41 PM

Cute but no, the code in question required a rewright as the logic was wrong. The spelling errors were a result of removing information prior to posting, they never existed in the actual code. Thanks for your concern though.

<{POST_SNAPBACK}>

He does have excellent spelling.
It is a waste of energy to be angry with a man who behaves badly, just as it is to be angry with a car that won't go. - Bertrand Russell

#33 Raindancer

Raindancer

    Polymath

  • Active Members
  • PipPipPipPip
  • 229 posts

Posted 15 September 2005 - 06:39 AM

As I requested, please state your company so I know to avoid them.  I would also like it if you cited your source(s) for learning programming as I would also like to avoid those, too.  Anybody advocating the use of "goto" in any functional language is a horrible programmer and should be promptly taken out into a field and shot.  Their code should also be destroyed and perhaps even burning the hard drives the code was stored on might atone for such foolishness.

<{POST_SNAPBACK}>

I think that would be the proper action to take on someone using goto... ;)
Say: "Chuchichäschtli"My UDFs:_PrintImage UDF_WinAnimate UDFGruess Raindancer

#34 /dev/null

/dev/null

    Universalist

  • MVPs
  • 2,946 posts

Posted 15 September 2005 - 07:03 AM

Cute but no, the code in question required a rewright as the logic was wrong. The spelling errors were a result of removing information prior to posting, they never existed in the actual code. Thanks for your concern though.

<{POST_SNAPBACK}>

Again: So, you "added" subfunctions to exactly what??

Kurt
__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

#35 Nutster

Nutster

    Developer at Large

  • Developers
  • 1,450 posts

Posted 15 September 2005 - 04:02 PM

Hmm, interesting, Idea. Do you happen to be anywhere near Toronto, so you can take one of my programming classes, or maybe near a community college so that you can learn what modern programming is really about? Or is high school more your speed? The teachers at high school usually know more about teaching than the instructors at community college, but the guys at community college tend to know more about programming, as they (we) usually are programmers first, teachers second, not the other way around. Did you listen to your teachers when they taught you about programming in something more advanced than Commodore 64 Basic?

I've already implimented a limited form of GoTo similar to how Java does it.

<{POST_SNAPBACK}>

How Java uses Goto? ;) Java disables goto. It is still a reserved word, but it has no valid context (not that it really had a logically valid context within a structured language anyway). But don't just take my word for it. Look at these sites.

From Sun's Java documentation

In the Java programming language, goto is a reserved word; the Java programming language does not have a goto statement. However there are alternative statements that you can use in the Java programming language in place of the goto statement.

Also look at another Sun Java page,

Java has no goto statement. Studies illustrated that goto is (mis)used more often than not simply "because it's there". Eliminating goto led to a simplification of the language--there are no rules about the effects of a goto into the middle of a for statement, for example. Studies on approximately 100,000 lines of C code determined that roughly 90 percent of the goto statements were used purely to obtain the effect of breaking out of nested loops. As mentioned above [Earlier in the web page; refer to original document], multi-level break and continue remove most of the need for goto statements.

Or more clearly from another publisher's site:

Note: Although goto is a reserved word, currently the Java language does not support the goto statement. Use Branching Statements instead.

Branching statements in Java are while, do ... until, for, if ... else, switch ... case, break, continue, return which are analogous to the structures and keywords we have in AutoIt. The error processing that Java and C++ have are not implemented in AutoIt, but look at @Error for error status information. It is outlined in each function's documentation.

I hope that puts this issue to rest. :P

Edit: Fix speeling and errors grammatical. Made a couple of points more clear.

Edited by Nutster, 15 September 2005 - 04:41 PM.

David NuttallNuttall Computer ConsultingAutoIt allows me to re-invent the wheel so much faster.An Aquarius born during the Age of AquariusI'm off to write a wizard, a wonderful wizard of odd...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users