It is my feeling that since LOLCODE is the most modern of languages, it should support full object-orientation and message-sending. Below is my suggested syntax, lowercase items being there to show where you'd make substitutions:


BTW I am going to define a class called 'pokemans'
HAI
LET ME SHOW U MY pokemans

  BTW This is a class variable
  THEY HAVE A VAR IT IS CALLED awsumness

  BTW This is an instance variable
  IT HAS A VAR IT IS CALLED height

  BTW This is an example of a typed statement
  IT HAS A pokeman IT IS ITS friend

  BTW --------------------------------------
  BTW Here's how we define LOLMETHODS

  IT CAN eat UR pokeman WATCH
    BTW Here a pokeman is passed in as an argument
    BTW and this instance check to see if it can be
    BTW eaten
    CAN I EAT UR pokeman
      AWSUM THX
       LET ME eat UR pokeman
      O NOES
       I NO WANT pokeman
       BTW ... and return it back to you
       HAVE UR STOOPID pokeman BACK
    KTHX
  KTHX

  BTW --------------------------------------
  BTW Here's a class method

  ALL MY pokemans CAN help UR teem WATCH
   BTW Just for demonstration, we'll see if
   BTW the passed 'teem' has a method on it's class
   BTW the 'ALL OF' indicates the 'class of' instead of the thing itself.
   CAN I hit ALL OF UR teem
    AWSUM THX
      LET ME hit ALL OF UR teem
    O NOES
      I NO WANT teem
    KTHXBYE
   HAVE UR STOOPID teem BACK
  KTHX

KTHX
KTHXBYE

Instantiating them is pretty easy:


  HAI
  CAN HAS STDIO?
  I HAS A pokeman ITS NAME IS pikachu
  I HAS A pokeman ITS NAME IS evilpikachu
  LET MY evilpikachu eat UR pikachu
  KTHXBYE


Why change variables so much for object-oriented-ness? Just use IT/THEY/I for class/non-class variables, and ITZ/ITZA for values/objects:

LET ME SHOW U MY pokemans
  IT HAS A height ITZ 10
KTHXBYE

and

I HAS A pikachu ITZA pokemans

Zach, 2007/06/01 04:07


I love pretty much everything on this page. I think, at the expense of some consistency in the block termination syntax, classes should be ended with MY <classname> LET ME SHOW YOU THEM rather than KTHX. It just fits so well! :-D

Fred, 2007/06/03 21:24


First, I think we need to get the more fundamental features of the language sorted first, before we worry about OO etc. OO is plainly not a core feature of LOLCode, based on everything we've seen so far.

Second, I favor a Javascript-style prototype based OO method. It plainly suits the language better than explicitly declaring members, methods, etc. — Arachnid

We definiely need class inheritance, like this:

LET ME SHOW U MY pikachus THEYZ pokemans
   ...
MY pikachus LET ME SHOW YOU THEM

Cedric Shock, 2007/06/23 19:30