MangularJS

From Esolang
Jump to navigation Jump to search

MangularJS (MJS) is a restricted subset of NodeJS by User:PythonshellDebugwindow.

Restrictions

  • No periods are allowed in the source code, in a string or otherwise, nor are any escape codes that would produce a period
  • Bracket notation, including for arrays, is not allowed
  • Square brackets in the source code are not allowed
  • Non-function-containing variables are not allowed, in fact the = operator is unused
  • All numbers are either integers or NaN
  • The 'alert' function is undefined
  • Division is floor division
  • The 'eval' function is undefined
  • Strings are delimited by : colons instead of quotes; colons in strings can't be escaped or replaced by any equivalent escape codes, as these are treated as non-escaped colons

More may be added in the future.

Examples

Hello, World!

with(console) log(:Hello, World!:);

Variable

// You will have to call this variable to get its value, as it is really a function
// Initialize to 123
function myVar() {return 123;}
// Set to 456
function myVar() {return 456;}
// Increment (don't change tmp_0)
function tmp_0() {return myVar();}
function myVar() {return tmp_0() + 1;}
//Not portable at all

Stack class

function Stack() {
  return {stack: Array(), push: function(x) {
    with(this) {
      with(stack) {
        push(x);
      }
    }
  }, pop: function() {
    with(this) {
      with(stack) {
        return pop();
      }
    }
  }};
}

See also