Class as first-class object
Posted
by
mrpyo
on Programmers
See other posts from Programmers
or by mrpyo
Published on 2011-08-17T19:08:14Z
Indexed on
2012/06/01
4:48 UTC
Read the original article
Hit count: 283
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).
© Programmers or respective owner