names for init block keywords?
"Mark Hahn" <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
When I was putting in the 2-tier proposal I put in this code sample:
object Widget:
defInit: Widget.protoName_ = 'Widget' #decorator
def init_(partNum):
blah blah blah
This made me realize that the new keyword "defInit" was too close to the
standard "def Init_" that is used all the time. This would be confusing.
These two (defInit and runInit) are also the only two camelcase keywords
which is not good.
Let me explain once again what the "defInit" and "runInit" keywords do and
ask you to help me find new simpler and clearer keywords. The full proposal
is at: http://prothon.org/wiki?pagename=FunctionInitBlocks.
These keywords appear near at the top of a function block and define blocks
of code that run at function initialization time. A defInit block runs at
definition time just as if the block appeared after the def block. The
runInit block runs at run (call) time exactly where it is, but it only runs
once the very first time the function is called. The defInit block is for
the "decorator" or "wrapper" concept and the runInit block is to initialize
static variables.
def f(x,y,z):
defInit:
f = resCache(logger(f), cacheSize = 500)
runInit:
f.staticVar = 0
Ideas for defInit:
init: def: decorate: after:
Ideas for runInit:
init: static: once: first: