Demlang

From Esolang
Jump to navigation Jump to search

Demlang is an object-oriented joke language created by User:Cocosbeans in 2025. The concept of the language is that any data created in a file, including variables/values, objects/classes, and functions, can only be accessed in the scope in which they are defined. Therefore, scopes serve as "object permanence".

Concept

Demlang was created to make it feel as though the computer has "dementia" and lacks object permanence. Values and objects in Demlang are only accessible in the same scope they are defined in, and scopes can be defined as any block of code that is put between two curly braces. Nested scopes cause data to be forgotten from memory if the nested scope is evaluated; if the nested scope is never evaluated (i.e. it has a condition that fails), memory will persist.

{
   let x = (int) 5;
   let y = (int) 10;

   if (false) {}
   
   //x and y are not forgotten because the if statement fails
   let z = (int) x + y;

  if (true) {}

  //x, y, and z no longer exist in memory
  let a = (int) z; //error
}

Due to how scopes work, classes can never be used because their fields are always forgotten after declaration and can't be initialized. This also applies to functions, where despite having the ability to return a value, it cannot be used.

Etymology

The name Demlang is short for dementia language. The language was originally supposed to be based around how babies do not have object permanence until a few months into infancy, but Babylang is already an existing name.

Syntax

The syntax of Demlang is modeled after C#. Its libraries are PascalCased and its primitive features are named the same as they are in C# (e.g. int, string, ushort).

Libraries

Libraries can be imported with the use command. This imports the source file of the library. Specific classes and functions can also be imported without importing the rest of the file. Libraries follow the pattern of Folder1.Folder2.File::BaseClass::Subclass:function.

use Core; //import all std features
use Math.Alg; //import the algebra library in the math folder
use Math.Trig::Trig; //import the trigonometry class in the trig file
use Math.Calc::Calc:GetDerivative; //import the getderivative function in the calculus class

These libraries can be accessed by simply naming which imported class to be used:

let f = (Alg.Expr) Alg.GetExprFromStr("3x^2+2x-6");
let fprime = (Alg.Expr) GetDerivative(f);

This page is a WIP.