Open seigakaku opened 1 year ago
Currently, although it should theoretically be possible to achieve through some MOP (Metaobject Protocol) tricks, subclassing a GObject class in Lisp is still quite difficult. This is because it would require re-implementing the macros that are present in C. Additionally, introducing MOP might require refactoring the object representation in cl-gobject-introspection because, at present, using type-of
in Lisp cannot differentiate between different types of GObjects. Therefore, this would be a significant undertaking. At this stage, I believe using strings to fulfill your requirements is a good solution. Lisp provides prin1-to-string
and read-from-string
, which allow for easy conversion between strings and Lisp data structures as long as unreadable objects are not involved.
I understand, strings work fine, I wanted to use integers merely as an optmization, but it's not a problem, thank you for your answer.
I have a situation where using a GtkStringList to maintain a tree view would be wasteful, as I have directly mapping indexes to an array. As far as I understand from the GTK documentation, GListStore items must be subclasses of GObject.Object, so to use integers, in C I would have to create a new GObject with my integer field, but I can't seem to find a way to do that in cl-gtk4. This was mentioned in #27 but you ended up providing an alternative solution. Perhaps my idea of subclassing GObject is suboptimal as well and there is a simpler way to use fixnums?