[Home]AlternativeNamedParameterSyntax

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Showing revision 10
THIS HAS BEEN IMPLEMENTED

After a discussion on IRC (December 30, 2006) about how nasty the proposed named parameter syntax looks (Named Parameters), here is an alternative.

#<named parameter here>
references a named parameter. The <> characters provide for neat bracketing that is relatively unobtrusive compared to using
#named parameter here$
with a $ terminator. These parameters would be local to the scope in which they were assigned.

#<_global named parameter here>.
Named parameters beginning with '_' are global. They are accessible from within called subroutines and may set values within subroutines that are accessible to the caller. As far as scope is concerned, they act just like regular numeric parameters. They are not stored in files.
Note: a choice was made to have the default define *local* parameters while the '_' case defines global parameters. The reason for this is that local parameters are probably more common.

Note: the global parameters _a, _b, _c, ... _z have been reserved for special use. In the future, they will provide access to the last Aword, Bword, Cword, etc. This will be used as part of an implementation of User Defined Gcodes.


Note: all parameter names are converted to lower case and have whitespace removed. This is an unfortunate consequence of the rs274ngc standard.
(Note: named owords have not been implemented yet)

Named owords can have a similar syntax.

o<a label> is a named label. Named labels are of local scope with the exception of the named labels which refer to subroutines. Thus, two subroutines may have owords "o<Loop>" without causing an error.

 o<BoreHole> sub
 o<BoreHole> return
 o<BoreHole> end
 o<BoreHole> call

All refer to the same subroutine.


Local named owords are stored internally as the subroutine name, followed by an '_', followed by the local oword name. In the case of a local named oword that is not within a subroutine, the letters 'main_' are prepended to the name. The character '_' may be part of an o_word name, but may NOT be the first character.
Also implemented new comment features

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions | View current revision
Edited April 21, 2007 1:10 pm by Lerman (diff)
Search:
Published under a Creative Commons License