Private methods in modulesNormally all variables and methods in Helma-NG modules are "public", but there is a way to create private ones:
Instead of passing the global object as argument, one can also use "this" inside the method to reference the module's scope (so "scope.publicMethod" becomes "this.publicMethod"), however imho it's quite confusing. |
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Helma NG Wiki
Wiki
Tags
Updates
Related Projects
Sites using Helma
Shop
search
tags for this page
all tags
Tagsapps (1) bugs (2) class (1) community (2) compatibility (1) concurrency (1) continuations (2) Documentation (6) dogfood (1) formatting (1) gobi (1) helma (6) helma 1.6 (13) helma 1.7 (8) helma 2 (11) helma ng (17) hopobject (1) html (1) inheritance (5) introspection (1) java (2) javascript (5) jetty (1) JSDoc (1) lazy (1) marius person (1) metaprogramming (2) modules (3) oop (1) organization (2) ORM (2) parsing (1) plugins (1) project (2) projects (1) prototype (1) Rabbit (2) Reference (1) REPL (1) rhino (4) roadmap (3) shell (1) shop (0) Skin Rendering (5) Snippets (1) source svn (1) sugar (3) templates (13) testing (4) Tobi (7) xml (1) Pages linking to this page: Wiki Overview Text Draft, wiki |
Comments
#1 by hannes at 2008/05/12 18:49Actually, "global" is the per-thread scope - the one that acts as prototype of all module scopes within one request as shown in this diagram. If you want to install public properties in the module scope, you should use "this" instead of "global" as function argument. But of course it's legitmate to install stuff in the per-thread global object. The helma.simpleweb module does this to set the global res, req and session properties.
#2 by hannes at 2008/05/16 22:08I just read the last sentence - why do you think using "this" is confusing? Actually, I prefer using "this" to "self" as it feels more natural, and I feel like settling on this variant: