From: Rick M. <obj...@gm...> - 2013-11-24 16:06:46
|
Ran into this little glitch this morning with a program I was writing. I created a class that started with the characters "3D", and was getting an error when i tried to instantiate it because the corresponding environment symbol resolved to a string value. I opened bug 1212 to address this. One of the first things I encountered was the docs for environment symbols, which requires that the first character not be a digit (section 1.13.6 in the reference). So, in a sense, this is working correctly, although with a high astonishment factor. The ::class directive does not place any restrictions, allowing you to create classes that you can't look up via environment symbols. For example, say .context~package~classes["INVALID NAME"]~new say .3dglasses~new ::class 3DGlasses ::method init say "Creating 3D Glasses" ::class "invalid name" ::method init say "Creating a funny instance" It seems like a reasonable thing to create a class name like 3DGlasses, but the current definition of environment symbols pretty much precludes this. I see a number of possibilities here; 1) Do nothing other than add some documentation to the ::CLASS directive explaining the implications of the name choice. 2) Change the definition of environment symbol to a restriction on the second character to "the remaining part of the symbol cannot be a valid Rexx number'. 3) Implement restrictions on the ::CLASS directive such that the name must be a valid environment symbol. I'm not terribly fond of solution 3), I'm sort of in favor of 2, but can live with 1. Thoughts? Rick |