1. wish list : functions within funcions
- Posted by =?iso-8859-2?B?qWtvZGE=?= <tone.skoda at SIOL.NET> Apr 08, 2000
- 435 views
------=_NextPart_000_001B_01BFA18E.07242320 charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable I really miss the ability of language to use functions within functions. = If you want to do one thing often within function, but that thing is = specific only for that function. Now you have to write new function, = which has name similar to parent function, but is used only within one = function. ------=_NextPart_000_001B_01BFA18E.07242320 charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-2" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3401" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>I really miss the ability of language = to use=20 functions within functions. If you want to do one thing often within = function,=20 but that thing is specific only for that function. Now you have to write = new=20 function, which has name similar to parent function, but is used only = within one=20 ------=_NextPart_000_001B_01BFA18E.07242320--
2. Re: wish list : functions within funcions
- Posted by Kat <gertie at ZEBRA.NET> Apr 08, 2000
- 744 views
----- Original Message ----- From: "Skoda" <tone.skoda at SIOL.NET> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Saturday, April 08, 2000 12:09 PM Subject: wish list : functions within funcions >I really miss the ability of language to use functions within functions. If you want to do one thing often within function, but that thing is specific only for that function. Now you have to write new function, which has name similar to parent function, but is used only within one function. That's called function overloading, in Eu, this can be easy. Pass the function a sequence, then parse the sequence within the function to see what should be done to it: *UN*tested code!! function dothings(sequence data) if sequence(data[1]) then if ( data[1] = "puts" ) then puts(data[2],data[3]) elsif ( data[1] = "DoSomethingElse") then DoSomethingElseHere elsif ( data[1] = "DoSomethingElse#2") then DoSomethingElse#2Here end if else if (data[3] = "add") then return data[1] + data[2] end if end if end function -- dothings dothings("puts",1,"hello") dothings(1,2,"add") Kat
3. Re: wish list : functions within funcions
- Posted by Kat <gertie at ZEBRA.NET> Apr 08, 2000
- 441 views
Ooops.. i forgot some { } in the *UN*tested code... see if you can spot where Kat ----- Original Message ----- From: "Kat" <gertie at ZEBRA.NET> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Saturday, April 08, 2000 3:39 PM Subject: Re: wish list : functions within funcions > ----- Original Message ----- > From: "Skoda" <tone.skoda at SIOL.NET> > To: <EUPHORIA at LISTSERV.MUOHIO.EDU> > Sent: Saturday, April 08, 2000 12:09 PM > Subject: wish list : functions within funcions > > > >I really miss the ability of language to use functions within functions. If > you want to do one thing often within function, but that thing is specific > only for that function. Now you have to write new function, which has name > similar to parent function, but is used only within one function. > > That's called function overloading, in Eu, this can be easy. Pass the > function a sequence, then parse the sequence within the function to see what > should be done to it: > > *UN*tested code!! > function dothings(sequence data) > if sequence(data[1]) then > if > ( data[1] = "puts" ) then puts(data[2],data[3]) > elsif > ( data[1] = "DoSomethingElse") then DoSomethingElseHere > elsif > ( data[1] = "DoSomethingElse#2") then DoSomethingElse#2Here > end if > else > if (data[3] = "add") then return data[1] + data[2] end if > end if > end function -- dothings > > dothings("puts",1,"hello") > dothings("DoSomethingElse",12,{23,"forty",{"abacus","albatros"}}) > dothings(1,2,"add") > > Kat >
4. Re: wish list : functions within funcions
- Posted by Evert van Dijken <evert.van.dijken at CMG.NL> Apr 09, 2000
- 455 views
When I understand the problem well, the anser is quite simple. Just put the function you wat to use a level higher (In front of the first function in which you want to use the common function) and everything goes fine.
5. Re: wish list : functions within funcions
- Posted by =?iso-8859-1?B?U2tvZGE=?= <tone.skoda at SIOL.NET> Apr 11, 2000
- 436 views
- Last edited Apr 12, 2000
what i meant was that it would be nice if you could use *local* functions, just like variables are local to function/procedure. the main reason for this wish is that the name of function could then be simple, and it would be also clearer. In C you can use macros (with #define) and then undefine them at the end of the function (at least thats what i did)