I’ve been playing with some of the more obscure parts of Squirrel and found that I can only add attributes </ … /> to classes and not to objects inside the classes. Was this a deliberate omission?
That said, the syntax of attributes (as defined in the squirrel-lang.org docs) is ugly.
Yes. Squirrel attributes, which didn’t strike us as being that useful, were removed, at least on the device, for code-size reasons. It’s really an oversight that they got left in on classes.
Did you find something worth using them for, then?
Well, I expose some objects and their methods for execution via a REST interface. I ended up implementing a separate data structure that holds detail about the methods (ie number and types of parameters). But, I had wondered whether I could do this with attributes. It’s basically reflection for squirrel.
However, I use a lot of tables for code too. If attributes were not available for tables as well as classes, then it wouldn’t be worth it.
One major challenge has been detecting whether a method requires a callback or not. I end up calling methods first without a callback, then with a callback if the first call fails. An attribute could immediately tell me in advance. What would be even more useful for this would be support for getinfos()