Label: ♦english ♦feature request
Pompei2 created at 4, 2011-02-09, 23:17:41
6 Replies, 3558 Hits
I tried all routines and found none to list me all classes and routines of a namespace, thus I concluded that there is none yet, right?
It could be as simple (?) as allowing the "constant" and "variable" methods to accept namespaces as parameters, I could then use it like:
reflect.constant(reflect.namespace())Which I would expect to give me a list of classes and routines defined in the given namespace. (That is the current namespace in the above example.)
Also, there is a complete lack of reflection support in any of the lately added features. Amongst the possible candidates I am thinking of are: (from most to leas important to me)
Finally, using a method called "constant" to get a list of routines feels awkward to me. I can understand the implementation-side reason for it, but any sane user would think it just returns the actual constants defined in the class. The documentation "Return the constant fields of object, ..." doesn't alleviate that either :-) My proposal would be to have "constant" really only return constants, adding a new method called "routines" which returns routines only. And yet another one "metafields" returning only the meta-fields, etc. :)
And while I'm at the names, I'd add an "s" to the name of all the reflection routines that can return more than one value, i.e. that return a list. For example, it should be "constant s ", "param s ", etc.
That's all from me for today, it's more than enough :-)
fu commented at 5, 2011-02-10, 08:46:56
I have been considering to remove "reflect", and redesign some essential reflection functions as part of "std" (which also need some redesigning). Your suggestions seem very helpful for this.
Pompei2 commented at 5, 2011-02-10, 11:51:43
Pompei2 modified at 5, 2011-02-10, 14:16:41
Great! A powerful reflection library (depending on the size, I would probably keep it in "reflect" in order not to grow "std" too much) is very important for language-supporting libraries. I'm prototyping a unit-testing library and really felt the need for it :-)
Edit: funny thing, I just saw this commented-out line in DaoQtCore.dao
#stdio.println( reflect.constant( reflect.namespace() ).keys() );Seems that what I asked for was supported some time ago :-)
Pompei2 commented at 6, 2011-02-11, 10:12:50
I don't report this as a bug, because you want to redesign the whole reflection thing anyway, but the string version of reflect.isa doesn't seem to work:
(dao) io.println(reflect.isa(Exception.Error("Hi"),"Exception.Error")) 0 (dao) io.println(reflect.isa(Exception.Error("Hi"), reflect.type(Exception.Error("Ho")))) 1 (dao) io.println(reflect.isa(Exception.Error.Value("Hi"), "Exception.Error")) 0 (dao) io.println(reflect.isa(Exception.Error.Value("Hi"), reflect.type(Exception.Error("Ho")))) 1The output should actually always be 1.
fu commented at 7, 2011-02-12, 05:53:39
Right, they were supported before, but were then broken due to some changes in the implementation of namespace and class.
fu commented at 7, 2011-02-12, 05:56:29
"Exception.Error" is not supported in type name, if you use
io.println(reflect.isa(Exception.Error("Hi"),"Exception::Error"))it will work. This will be fixed.
Pompei2 commented at 7, 2011-02-12, 09:55:39
Seems it is the same error I did as in my bugreport, thanks for pointing this out :)