Defining Functions / Procedures

2 views
Skip to first unread message

Duke Normandin

unread,
Dec 9, 2021, 8:45:49 PM12/9/21
to Pike List
Greetings ..

function hello =lambda() {}

or

void hello() {}

In Pike, which form is prefered or optimal? Why?
TIA ...
--
Duke
** Text only please. Bottom post is best. **

Chris Angelico

unread,
Dec 9, 2021, 10:09:38 PM12/9/21
to Pike List
On Fri, Dec 10, 2021 at 1:10 PM Duke Normandin <dukeo...@gmx.com> wrote:
>
> Greetings ..
>
> function hello =lambda() {}
>
> or
>
> void hello() {}
>
> In Pike, which form is prefered or optimal? Why?
> TIA ...


Definitely the second, unless you need it to be a variable.

ChrisA

Duke Normandin

unread,
Dec 9, 2021, 11:34:34 PM12/9/21
to Pike List
On Fri, 10 Dec 2021 15:28:59 +1100
Chris Angelico <ros...@gmail.com> wrote:

> On Fri, Dec 10, 2021 at 3:06 PM Duke Normandin
> > Thx Chris! So - if I understand you correctly, the lambda form
> > is available to provide first-class functionality, i.e. the
> > capability of assigning a function to a variable, etc?
>
> The function itself is always a first-class object, but the lambda
> form allows you to reassign it:
>
> function hello = lambda() {};
>
> // ... later ...
>
> hello = lambda() {/* something else */};
>
> Not something you'll often need, but when you do need it, the
> option is there.

Got it! Thx
Reply all
Reply to author
Forward
0 new messages