[lively-kernel] Contributing source code to the Lively Kernel

Adam Spitz adam.spitz at gmail.com
Wed Apr 14 17:19:50 CEST 2010


Robert Krahn wrote:

> Part 2: Using modules to add your extensions
> The first thing you need is some place to store your source code and your
> data. You can create your own subdirectory in the wiki
> here: http://www.lively-kernel.org/repository/lively-wiki/CreateUserDirectory.xhtml
> Your directory includes a WorldTemplate.xhtml that you can clone to create
> new pages. You can then add new Worlds and add source code in them using the
> local changes (and the Local code Browser, you find it in the Tools menu).
> Or you can create your own JavaScript files using the System browser or
> manually by checking out your directory using SVN and adding/editing files
> with a TextEditor. The JavaScript files should include a module definition.

I'm confused about all these different tools.

The System Code Browser (which I originally thought would be like a
Smalltalk browser, showing me what's in the live image) seems to be
showing me what's in the system code *files*. When I first open it up,
it says that everything, even the core stuff (Core.js, Text.js, etc.),
is "not loaded." Then when I click on the file name, it "loads", which
I take to mean that the system is parsing the file and showing me
what's in it (rather than showing me the actual code that's in the
live image). If I make a change in there and hit Apple-S, it saves the
change, and that change is visible if I hit my browser's Reload button
or even open the world in another browser. So it obviously saved my
change to a file somewhere. Where's the file? The only file in
http://www.lively-kernel.org/repository/lively-wiki/users/AdamSpitz/
is the WorldTemplate.xhtml file (I don't see any .js files there), so
I hope I didn't just overwrite some important official LK file or
something.

And then there's the Javascript Code Browser, which I can open by
right-clicking any morph and saying "show class in browser." If I make
a change *there*, it seems to be only changing the running image -
when I reload the page my change is gone. Good, that makes sense to
me.

Incidentally, I noticed that after I've opened a System Code Browser,
the Javascript Code Browser doesn't seem to work anymore - I get an
error message in the console saying, "TypeError: Result of expression
'this.methodDicts' [undefined] is not an object." (Did I just cause
this error by mucking around with system files?)

Is the System Code Browser just meant to be a way of editing .js
files? (That is, it doesn't operate on the live image, it's just a bit
nicer than Emacs for editing .js files?) Is the idea that most
"normal" programming (programming that isn't likely to crash the whole
system if you make a typo) should be done in the Javascript Code
Browser?



> ** Using the namespace inside a module is NOT enforced. This means if you
> define a class Object.subclass('SystemBrowser', {...}) it will "extend" the
> Global namespace. This means that you can access the class via
> Global.SystemBrowser (or simply with SystemBrowser). Only if you use the
> namespace explicitly Object.subclass('lively.ide.SystemBrowser', {...}) the
> namespace will be used and you can access the class via
> Global.lively.ide.SystemBrowser (or simply lively.ide.SystemBrowser).
> We might change that in the future to enforce namespace usage.

If you do that, will it still be possible for me to write, say, a
"set" class and add an asSet method to the Array class?

Come to think of it, how does the current system know how to find
"extension" methods like that and file them out when you file out the
module that they belong to? In Self's module system (and in my port of
it to LK), the module object itself keeps track of all the slots
belonging to the module. But I don't think I've seen anything like
that in LK. (I could easily have missed it, though.)



Adam


More information about the lively-kernel mailing list