Idea.1 - an approach for namespaces
Page 1 of 1

Author:  ldl [ Tue Nov 23, 2010 10:34 pm ]
Post subject:  Idea.1 - an approach for namespaces

Presently the VISTA SAC (Standards And Conventions) describes the use of
VISTA Number and Name Spaces (VNNS). The conventions used are, IMO,
rather hard to deal with because the variable names become too hard to deal
with for typical namespaces (of 3 or 4 characters, short 1 or 2 character name
spaces are bad enough, but very difficult to obtain).

The following idea is one that would allow the source code to be preprocessed
into conventional MUMPS, where the tools (such as VPE, Eclipse, etc) would
deal with the substitution.

A downside, clearly, is that anyone looking at the resulting MUMPS code would
not get the benefit of the notational clarity of the original... BUT all of the coding
information for the "original" is preserved in the processed source... so "round
trip" (to and from) should be possible from either.

# $Id: Idea.1,v 20080220.1 2008/02/21 04:54:40 ldl Exp ldl $
# vforum:$Source: /home/vforum/RCS/Idea.1,v $

The localized namespace problem severely highlights the
failure of the current M[UMPS] Standard (and implementations)
to address access and control of the symbol table.

Current recommended VistA practice significantly impedes the
readability of the resulting code, by:
- do not allow for clear, nor safe names
- exchanging hard to keep straight symbol table problems with
unreadable code (twisty little variations of the endings of
variable names, running the significant risk of confusion)
- comments attempting to rectify the above are completely
inadequate and they tend to create a "second program" (a
program within a program) that needs to be maintained so
as to not mislead the reader.

An idea for namespaces without needing M[UMPS] extensions.

- Allows for "mangling" of the descriptions without having to
visually clutter the source code.

- Allows for "mangling" the desciptions without requiring VPE.

- Use a conventional dot notation to separate namespace from
namespace element to avoid confusion with pass by reference

- Tag externally visible labels with a leading '&' (similar
to existing M[UMPS] referencing of external library packages

- Labels lacking the "external" '&' tagging are private

- Label "mangling" provides strong visibility of externally
accessible tags, and automatically (lightly) hides local
private tags.

- Keep description in the routine following the reserved tag,
here using "NAMESPEC", but it could be any tag we decide on.

- Spec is accessible via $TEXT() for introspection and other
mechanisms we desire.

- Almost no thought has been put into where this can go, but
lots of ideas are rolling around, including the ability to
coordinate namespaces with "include" or other mechanisms.

The main idea is that VPE (or other process) is able to de-ugly
(or less ugly) the routine by annotating the code in a more
conventional namespace form, while not changing what the
resulting M[UMPS] code sees.

Items known to be missing (but seen as tractable):
- Namespace replacement within strings, if even needed

Sample Source code that VPE munges to/from routine source

VPE display of the routine
| 1 X.1 ;;VistA Header 1
| 2 ;;VistA Header 2
| 3 Q
| 4 &MAIN ; Main entry point
| 5 N X.SAM S X.SAM=""
| 6 F S X.SAM=$O(^GVN(X.SAM)) Q:X.SAM="" D
| 7 . D SUB(.X.SAM)
| 8 Q
| 9 ;
| 10 SUB(X.VAR) ; Private routine SUB
| 11 W X.VAR,Y.MAX,!

| Namespace Description
| --------- -----------------------------
| ZLDL Description of namespace ZLDL
| ZDLW Description of namespace ZDLW

| Namespace Variable Type Description
| ---------- ------------- ------ ----------------------------------
| ZLDL X.PETE String Description of PETE
| X.SAM String Description of SAM
| X.VAR String Description of VAR
| ZDLW Y.MAX Number Description of MAX

Routine source for the above
ZLDL1 ;;VistA Header 1
;;VistA Header 2
XSUB(ZLDLVAR) ; Private routine SUB
NAMESPEC ;; <XML 'various XML chatter'>
;; Description of namespace ZLDL
;; <VAR NAME="SAM" TYPE="String">Description of VAR</VAR>
;; <VAR NAME="PETE" TYPE="String">Description of PETE</VAR>
;; <VAR NAME="VAR" TYPE="String">Description of VAR</VAR>
;; Description of namespace ZDLW
;; <VAR NAME="MAX" TYPE="Number">Description of MAX</VAR>
$Log: Idea.1,v $
Revision 20080220.1 2008/02/21 04:54:40 ldl
Initial hack

Revision 20080220.1 2008/02/21 04:51:18 vforum
initial hack

End of $Id: Idea.1,v 20080220.1 2008/02/21 04:54:40 ldl Exp ldl $

Author:  toad [ Tue Feb 15, 2011 6:44 pm ]
Post subject:  Re: Idea.1 - an approach for namespaces

I have a different idea for making VISTA namespaces more manageable, but I can't describe it until after we get the next MUMPS standard released because it would be a shiny distraction.

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group