Re: Defining Functions / Procedures

2021-12-09 Thread Duke Normandin
On Fri, 10 Dec 2021 15:28:59 +1100
Chris Angelico  wrote:

> On Fri, Dec 10, 2021 at 3:06 PM Duke Normandin
>  wrote:
> >
> > On Fri, 10 Dec 2021 14:09:21 +1100
> > Chris Angelico  wrote:
> >
> > > On Fri, Dec 10, 2021 at 1:10 PM Duke Normandin
> > >  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.
> >
> > 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

--
Duke
** Text only please. Bottom post is best. **



Re: Defining Functions / Procedures

2021-12-09 Thread Chris Angelico
On Fri, Dec 10, 2021 at 1:10 PM Duke Normandin  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