Class as first-class object
- by mrpyo
Could a class be a first-class object?
If yes, how would the implementation look?
I mean, how could syntax for dynamically creating new classes look like?
EDIT: I mean what example syntax could look like (I'm sorry, English is not my native language), but still I believe this question makes sense - how you give this functionality while keeping language consistent.
For example how you create reference for new type. Do you make reference first-class object too and then use something like this:
Reference<newType> r = new Reference<newType>();
r.set(value);
Well this could get messy so you may just force user to use Object type references for dynamically created classes, but then you loose type-checking.
I think creating concise syntax for this is interesting problem which solving could lead to better language design, maybe language which is metalanguage for itself (I wonder if this is possible).