Double sided double underscored variable names

Joshua Landau joshua.landau.ws at gmail.com
Tue Sep 11 18:09:40 EDT 2012


Were I to make a language to compile to Python, it is highly likely I would
need to use hidden variable names to work constructs that Python alone does
not have. This is the situation I face.

If I were to use internal double-underscored names of the form __BS_*
internalname*__, would the compiled code be able to assume that no-one had
overwritten these variables and never will, even through modification of,
say, locals(). I ask because Python's docs seem to specify that double
sided double underscored names are strictly for Python and its special
names.

In other words, is not using __these_names__ in Python code rule or heavy
convention.

__BS__ is used because the name of the language is BluntSharp. Do not
expect the language to ever be useful or widespread; I am doing this mostly
for fun.

An alternative is modifying the AST (as I am really compiling to Python's
AST) to have the variables with names such as "+BS_internalname", but that
seems like it might break a lot. I also doubt that it is good convention.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120911/7b8d2ad1/attachment.html>


More information about the Python-list mailing list