Re: Re: names for init block keywords?

Paul Prescod <[email protected]>
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Mark Hahn wrote:

> I'm leaning towards using "once" and "after".  I think they are very clear
> and intuitive.
> 
> def func():
>       """function to solve all the world's problems"""
>       after:
>             func = turbocharge(func)
>       once:
>             func.staticVar = 0
>       func.staticVar += 1
> 
> If no one objects I'll change this proposal and all examples in all
> proposals to use these keywords.
> 
> By the way, I find myself using both of these constantly now in my coding.
> I don't know how I ever lived without them.

In object oriented programs I find it very seldom the case that I need 
to do something on the first run of a function. For example your example 
is just as easily written:

def func():
       """function to solve all the world's problems"""
       after:
             func = turbocharge(func)
             func.staticVar = 0

       func.staticVar += 1

The only time it would matter is if the code in the once block had side 
effects and they really couldn't happen yet but could only happen later. 
Seems pretty rare to me and easily handled with static variables.

Not big on the keyword name "after".

"init:" or "initialize:" might be better.

  Paul Prescod
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.