Class vars as statics

35 views
Skip to first unread message

Charles Oliver Nutter

unread,
Oct 29, 2010, 10:46:08 PM10/29/10
to mi...@googlegroups.com
Someone asked me today if Mirah supported static fields, and I had
forgotten the answer. So I poked around and remembered that instance
vars in static methods end up being static, but you can't access them
from instance methods on the same class without adding an accessor
(since using @foo in an instance method would try to look for the
instance field).

So I started hacking in class vars (@@foo) to always access the static
var of that name: http://gist.github.com/654845

It almost works, but I'm having some inference problems (as usual). I
may not have time to hack on it again in the next day or two (RubyConf
Uruguay this weekend) so I thought I'd post it here if anyone wanted
to try to finish it up.

And oh, hi :) Hopefully I'll be able to do more Mirah hacking after
all my travel is done in a couple weeks.

- Charlie

Charles Oliver Nutter

unread,
Oct 30, 2010, 12:22:54 AM10/30/10
to mi...@googlegroups.com
Ahh, I found my bug. I was not properly passing true for static to
field accesses (Field.new), and then I wasn't passing along
static_field to field declaration during compile either.

It works now, pushed in 91c66d3.

- Charlie

Reply all
Reply to author
Forward
0 new messages