MagLev / maglev

GemStone Maglev Ruby Repository
http://maglev.github.io
517 stars 41 forks source link

Struct's name is not persisted #196

Open semaperepelitsa opened 11 years ago

semaperepelitsa commented 11 years ago

First script prints class name "Letter" as expected.

Maglev.persistent do
  p Letter = Struct.new(:char)
end
Maglev.commit_transaction

Second script prints empty line instead of class name.

p Letter

It works fine if I replace struct with a regular class.

timfel commented 11 years ago

i remember seeing this before. we talked about this, then. the problem is that assigning a struct to a comstamt doesn't actually set its name. the constant of the name Letter simply points to the new class, but that doesnt mean the name of the strucy class is now Letter.

A workaround could be

class Letter < Struct.new(:char); end
semaperepelitsa commented 11 years ago

But this works fine: Letter = Class.new.

timfel commented 11 years ago

I won't have time to look into it today (Christmas and everything ;)), but I'll take a look. Associating classes with names on the Smalltalk side of things happens through instances of RubyNamespace. We had some oddities there before. @MagLev/hpi-bp is working on persistence, so they will take a look, too.