Gauche > Archives > 2015/06/05

2015/06/05 03:43:55 UTCjames
#
I've got some quite old code here that I'm trying to run in modern Gauche, its mostly happy but it does some funky things with clos / mop and one sticking point is that gauche is unhappy with modifing the class after creation: "class is not malleable".

Is there a way to set this malleable attribute for a class?  Or should I rewrite this code to do things differently?
2015/06/05 04:00:15 UTCshiro
#
Class's malleable status is introduced as a safety net; it's unsafe to modify class structure except the certain stage of initialization. If you hit it even though you don't do anything seemingly dangerous, it could be a bug. Could you give me some code I can investigate?
2015/06/05 04:06:03 UTCjames
#
https://github.com/eval-apply/cm/blob/master/src/gauche.scm#L244
2015/06/05 04:06:07 UTCshiro
#
Hm, Gauche "freezes" the critical structure of a class at the end of (initialize ((class <class>) initargs)) method. If your metaclass's initialize method calls (next-method) first then want to tweak class structure, yes, you'll hit the malleability issue. Can't you do your thing in compute-cpl or compute-slots methods?
2015/06/05 04:06:54 UTCjames
#
I'm really not too sure about this codebase, I really just started digging in it.
#
As you say though it does seem like an unsafe way to do things
2015/06/05 04:07:47 UTCshiro
#
Seems that the offending part is setting class name afterwards.
2015/06/05 04:09:15 UTCjames
#
Yep, I'm not really sure has any affect in the rest of the code or not yet so I thought I'd ask about the malleable flag first. I can explore further though and remove it if its not used.
2015/06/05 04:12:22 UTCshiro
#
The safer way, for now, is to introduce a common metaclass, and define initialize method on it what modifies initargs before calling next-method. But I realized certainly that limits the option. Maybe an option to override class name by :name keyword argument for define-class macro would be nicer.
2015/06/05 04:30:28 UTCjames
#
No problems thanks for the advice. As an aside, been really enjoying using Gauche. Really nice scheme.