LIL is a Language Make games, nicely

@string

Strings are sequences of characters. They keep track of their length.

Example code

//use built in LIL strings
var myStr: "Hello world";
myStr.append(", have a great day!");

//or do it manually
var otherStr: @string { };
otherStr.initialize(`this is a c style string`, 24);

Member variables

  • length

    Type: var.i64

    The amount of bytes that are used in the buffer for storing the string.

    print myStr.length;
  • buffer

    Type: var.[56 x i8]

    The internal storage space for characters, using the short string optimization. When the string is long, it contains a pointer to the buffer on the heap.

    return pointerTo(@self.buffer) => cstr;

Member functions

  • construct

    Type: fn

    The constructor for this class. This method will be called automatically.

  • destruct

    Type: fn

    The destructor for this class. This method will be called automatically.

  • cstr

    Type: fn => ptr(i8)

    Returns a pointer to the characters as a C string, aka ptr(i8).

    var str: "This is a LIL string";
    doStuffWithCStr(str.cstr());
  • append

    Type: fn(ptr(@string))

    Add the content of the given string to the end of this one.

    Arguments
    • var.ptr(@string) otherStr:

      The other string, which will be added to this one.

    var str: "Hello there ";
    str.add("my friend");
    print str; //prints Hello there my friend to stdout
  • initialize

    Type: fn(ptr(i8),i64)

    Sets up the string and adds the given string as content. This method is the one that is called by the compiler when creating built-in strings.

    Arguments
    • var.ptr(i8) value:

      A null terminated C-style string.

    • var.i64 length:

      The amount of bytes that are needed to store the full sequence of characters, but WITHOUT the null terminator. The method automatically adds 1 to the length when necessary.