Benjamin Juang (ibneko) wrote,
Benjamin Juang

  • Mood:
  • Music:


Notes to self (although it may interest others who work on S2)
-There is no while or for loops. Foreach does work however, just like in perl (yay!)
-Arrays are dynamic. Calling something non-existent returns "" in a string array.
-You can have multi leveled arrays. Not really tested, but it compiles without problems.
-Strings are severely lacking in string-manip functions/methods. I'm writing my own functions to do string searches, because it's a) reusable code, and b) I hate putting ugly code like that in a function that's supposed to do something else.
-Compiler doesn't look ahead, so functions must be created early. Or at least started beforehand? doesn't work.
-Arrays can be accessed via foreach. Nice stuff.
-Classes are supported, but in a weird sense.
class stack
var string[] array;
var int top;
function push(string aString);
function pop() : string;

function stack::push(string aString)
$.array[$.top+1] = $aString;
function stack::pop() : string
return $.array[$.top+1];

function RecentPage::print_body() {
var stack aStack;
print $aStack->pop();

(NOTE: This is untested code, I wrote it to probe S2's class capabilities. Ought to compile without problems though)
-S2 is weird (read: annoying) in that a variable declaration uses "var [variable type] [variable name] [= value]. HOWEVER, when you want to use the variable, $[variable name] is required. This annoys me because I tend to type var int index, and then just index when I need to use the $index variable. This makes the compiler return annoy error messages that aren't always immediately clear.
-The compiler error messages are helpful if you READ them carefully and logically. Yes, Neko, I know you like using the guess-and-fail method of programming when trying out things, but you know, error messages are there for A REASON. Baka.

Ok, that's enough for now. I forsee a few more ugly surprises later on, in the actual printing-code-to-the-system part, but it looks like clear sailing for a while... Oh, and here's two string manip functions (actually four, two as the "interface" for the two recursive functions) that I'm starting to find useful.

function split_recursive(int stringIndex, string chunk, string tokens,
int arrayIndex, string[] ret) : string[]
if ($chunk->length()-$stringIndex < $tokens->length()){
$ret[$arrayIndex] = $chunk->substr(0,$stringIndex);
return $ret;
if ($chunk->substr($stringIndex, $tokens->length()) == $tokens){
$ret[$arrayIndex] = $chunk->substr(0,$stringIndex);
$chunk = $chunk->substr($stringIndex+1, $chunk->length()-$stringIndex);
$stringIndex = -1;
return split_recursive($stringIndex, $chunk, $tokens, $arrayIndex, $ret);
function split(string chunk, string tokens) : string[]
# This is based off java's string tokenizer
var string[] ret;
return split_recursive(-1, $chunk, $tokens, 0, $ret);

function replace_recursive(int stringIndex, string chunk, string target,
string replacement) : string
if ($chunk->length()-$stringIndex < $target->length()){
return $chunk;
if ($chunk->substr($stringIndex, $target->length()) == $target){
$chunk = $chunk->substr(0, $stringIndex)
$stringIndex = $stringIndex + $replacement->length();
return replace_recursive($stringIndex, $chunk, $target, $replacement);
function replace(string chunk, string target, string replacement) : string
return replace_recursive(-1, $chunk, $target, $replacement);

They're not commented because I've got better stuff to do right now. And those function names are pretty self-explanatory, aren't they? Split is from perl's string.split("tokens") functions and replace does what it says- replaces all instances of $target in the string $chunk with $replacement.

You know, I have to say I do love learning new programming languages... so fun~ Wish I has a permament account here so I could play around with S2 as they make changes. ^^;; Xella, I may have to ask you to make the layout public or give me the ID or something so I can create my own theme for the layout. Given the flexibility I'm working into the layout, it will be nothing like yours, I promise~ (mmm, I hope there's not too much flexibility... =o.O= )

The thing that worries me now is that part of the flexibility that I have added makes use of the belief that I can allow users to add their own "text" - and that the text can be inserted into certain places, like the style="" part of a div tag, giving them practically unlimited powers to the equivalent of the S1 style creator/editor.

Oh, and javascript still doesn't work. They check for that between the server and the user's browser. Anything between generated html "script" tags are removed. Pity, ne? Yes, I tried printing the letters of script one by one. Doesn't work.

  • Harry Potter and the Half Blood Prince

    Man, the Harry Potter movie made me wish I was back at school. Also, Harry, what's wrong with you? Everyone's standing respectfully away from…

  • Oh, why not..

    Annoying Things To Do On An Elevator 1) CRACK open your briefcase or handbag, peer Inside and ask "Got enough air in there?" 2) STAND silent and…

  • If you give an Engineer a Cookie...

    If you give an Engineer a Cookie... He's going to want to make another one. If he wants to make another one... He's going to have to have a…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded