Re: wish list : functions within funcions

new topic     » goto parent     » topic index » view thread      » older message » newer message

Ooops.. i forgot some { } in the *UN*tested code... see if you can spot
where smile

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
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu