KPL Variables

KPL variables resemble PHP variables in the sense that they are loosely typed and don’t have to be declared. For those new to programming, this means that you don’t have to declare that the variable is an integer or a text string.


Variable names must start with an alphabetic character followed by any alpha-numeric combination, underscores are allowed but any other non alpha-numeric character is forbidden. These are some Examples of correct variable names:

  • myVar
  • MyVar
  • myVar123
  • myVar_123


Nothing particularly special here, assignments are done using the “=” operator although when assigning another variable we need to dereference its value by wrapping the variable in “<>”. Here are some examples:

myVar1 = 123;
myVar2 = ~Some String~;
myvar3 = <myVar1>;
myVar4 = <myVar2>;


In KPL, we can assign integers and floating point numbers to variables and the language takes care of any necessary conversion. All the common operators are supported +, -, *, /, % (Mod) Here are some examples:

myVar1 = 1 + 2; // 3
myVar2 = <myVar1> * 2; // 6
myvar3 = <myVar2> % <myVar1>; // 6%3 = 0

Strings and Concatenation

Strings are particularly especial in this language, instead of using the common (“”) for declaring a string, KPL uses (~~). When working with the built in functions and passing values to them it is recommended to encapsulate¬† the passing variable with (~~). I imagine that this has to do with the loosely typed nature of the language. The concatenation operator is “+”. Concatenation is done by calling the variables inside a (~~) and using the “+” to join them together. Here are some examples to better illustrate what’s going on:

myVar1 = ~Some Text~;
myVar2 = ~More Text~;
myVar3 = ~<myVar1>, <myVar2>~; //myVar3's value is now ~Some Text, More Text~
myVar3 = ~<myVar1>~ + ~<myVar2>~; //myVar3's value is now ~Some TextMore Text~


Boolean variables are declared by using the common “true” and “false” keywords

myVar = true;


Since this is a loosely type language like PHP, type conversion is automatically handled. this is particularly useful when retrieving values from a database since they tend to be returned as text. Here are some examples of automatic conversions

myVar1 = 200; //Int
myVar2 = 30.5; //Float
myVar3 = ~23~; //String
myVar4 = <myVar1>+<myVar2>+<myVar3>; // myVar4 value is: 253.5
myVar5 = ~<myVar1>+<myVar2>+<myVar3>~; // myVar4 value is a String: ~200+30.5+23~


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.