Not approved.

1) Tried this in SWF9 doing some hand coding, and can't get around this compile error:

/private/tmp/lzswf9/lzgen64824/SingletonClass.as(6): col: 37 Error: Return value must be undefined.

    return SingletonClass.singleton;
                                    ^

So it does appear that 'new' is behaving like C++ or Java - the object is created, and the value of the reference is determined before the constructor is called.
Maybe use a pattern like this:

  class SingletonClass {
    private static var singleton:SingletonClass = new SingletonClass();
public static function instance():SingletonClass { return singleton; } function SingletonClass() { if (singleton != null) throw "Use SingletonClass.instance() instead of new"}
  }

usage: var s = SingletonClass.instance();

I added the throw because constructors cannot be marked private (at
least flex gives an error).


2) Here's how you would do a link to another page:

* @shortdesc Alias for <link linkend="LzCursorService">LzCursorService.LzCursor</link>

<link> allows/requires you to craft your own link text, e.g. LzCursorServer.LzCursor . As an alternative, you may use simply <xref linked="LzCursorService" / >, where the label of the link is determined for you (in this case it would be LzCursorService).

FWIW, I tried to also put such a link in the description of a variable:

/** The cursor service. Also available as the global <link linked="LzCursor"/>LzCursor</link>.
   * @type LzCursorService
   */
  static var LzCursor:LzCursorService;

but it doesn't work, and appears to lose that whole javadoc.
Not sure what the difference is, but <link> apparently can be
used in the description of a class as well as its @shortdesc.
Haven't gotten a workaround for that one yet.


On Mar 20, 2008, at 4:42 PM, P T Withington wrote:

[This is really an experiment to see how we might implement our singleton objects and whether the doc tools can do a better job with this pattern. The compiler/doc-tools need to be smartened to understand `interface` and `implements` to really do this right.]

Change 20080320-ptw-4 by [EMAIL PROTECTED] on 2008-03-20 16:34:26 EDT
   in /Users/ptw/OpenLaszlo/ringding-clean/docs/src
   for http://svn.openlaszlo.org/openlaszlo/trunk/docs/src

Summary: Redefine LzCursor using 'modern O-O'

Bugs Fixed:
LPP-5617 'LzCursor reference page problems' (partial)

Technical Reviewer: dda (pending)
Doc Reviewer: lou (pending)

Details:
   Redefine LzCursor as a global alias for LzCursorService.LzCursor
   which is a singleton class implementing LzCursorInterface by
   trampolining to LzMouseKernel.  This was all being done in a
   hand-crafted Object before, but the doc tools couldn't grok that
   at all.

Tests:
   LzCursor still works.  The documentation is different.

Files:
M      WEB-INF/lps/lfc/services/LzCursor.lzs

Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20080320-ptw-4.tar


--

Don Anderson
Java/C/C++, Berkeley DB, systems consultant

voice: 617-547-7881
email: [EMAIL PROTECTED]
www: http://www.ddanderson.com




Reply via email to