[Python-Dev] re: #pragmas and method attributes

gvwilson@nevex.com gvwilson@nevex.com
Wed, 12 Apr 2000 15:16:40 -0400 (EDT)


> > On Wed, 12 Apr 2000, Paul Prescod wrote:
> > About a month ago I wrote (but did not publish) a proposal that combined
> > #pragmas and method attributes. The reason I combined them is that in a
> > lot of cases method "attributes" are supposed to be available in the
> > parse tree, before the program begins to run. Here is my rough draft.

> Moshe Zadka wrote:
> BTW: Why force the value to be a string? Any immutable basic type
> should do fine, no??

If attributes can be objects other than strings, then programmers can
implement hierarchical nesting directly using:

def func(...):
    decl {
        'zorb'  : 'visible',
        'spark' : {
            'rule'  : 'some grammar rule',
            'doc'   : 'handle quoted expressions'
        }
        'info' : {
            'author' : ('Greg Wilson', 'Allun Smythee'),
            'date'   : '2000-04-12 14:08:20 EDT'
        }
    }
    pass

instead of:

def func(...):
    decl {
        'zorb'        : 'visible',
        'spark-rule'  : 'some grammar rule',
        'spark-doc'   : 'handle quoted expressions'
        'info-author' : 'Greg Wilson, Allun Smythee',
        'info-date'   : '2000-04-12 14:08:20 EDT'
    }
    pass

In my experience, every system for providing information has eventually
wanted/needed to be hierarchical --- code blocks, HTML, the Windows
registry, you name it.  This can be faked up using some convention like
semicolon-separated lists, but processing (and escaping insignificant uses
of separator characters) quickly becomes painful.  (Note that if Python
supported multi-dicts, or if something *ML-ish was being used for decl's,
the "author" tag in "info" could be listed twice, instead of requiring
programmers to fall back on char-separated lists.)

Just another random,

Greg