Brad Fitzpatrick (bradfitz) wrote in lj_dev,
Brad Fitzpatrick
bradfitz
lj_dev

More S2 fun

Just checked in a bunch more S2 work for mart. (told you I would, dormando)

You can now do this and have it spit out this. You can see the builtin implementations here. In that example, object interpolation in strings is done by accessing the class' asString string member, but if your class has a function named toString() with a return type of string, then it also just magically works (as seen here).

The only big problem remaining (as noted in BUGS) is that we need readonly or private class members (so you can't assign directly to a color's r/g/b values).

Oh, the big benefit of this batch of changes is that you can now do:

set bgcolor = "#ff0000";

and bgcolor is of type Color, not string. so the resultant backend code looks like:

register_set(1,"bgcolor",["#FF0000", sub {
my $_ctx = shift;
return LJ::S2::Builtin::Color__Color($_ctx, "#FF0000");
}]);

Anyway ... have fun. I think the S2 language stuff is done... new work will all be on the web interface while mart finishes up the core.s2 file.
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 13 comments