Deklare

From Esolang
Jump to navigation Jump to search
Deklare
Paradigm(s) declarative
Designed by User:A
Appeared in 2019
Memory system tape-based
Dimensions one-dimensional
Computational class Unknown
Major implementations None
File extension(s) .d, .dk

Deklare is a language invented by User:A where variables are initialized before they are declared.

Quick reference

  • a=b Says that the name a has the same value as the name b.
  • a=123 The name a has the same value as the name 123.
  • 123=123 Says that the number 123 is going to evolve into being equal to the number 123.
  • 123=a Says that the number 123 is going to evolve into being equal with a.

Example

a=b=c # a, b, and c are the same value.
d=e=f # d, e, and f are the same value.
a=d # a and d are the same value.
d=123 # d is 123. Therefore everything else is 123.

Another example

a=123 # a is the value 123
b=c # b should be the value of c
c=a # c should be the value of a (which is 123).

The arithmetic system

Obviously, without any operators other than the assignment operator, programs literally can't do anything. So here are some examples:

3 = b + 3 # We know that b+3 is equal to 3, but we don't know whether this is true or not.
b = 2 # This returns 0 because this value does not fullfill the above expression.
# There are quite a few of them: + - * / % = > < |

Challenge: loop over a few values

How do we do looping in Deklare? Well, that presents the real status of Deklare: everything is guessed.

So in this expression:

a = 2 + 2

# 2 could have evolved into any value, therefore we need something to limit the step down.
# The only possible evolution is by adding with 2.

# + is (kind of) a shorthand of |+, which means (evolve into) (adding with), so technically Deklare only has one dyadic operator.

# So = is a shorthand of |=, which means (evolve into) (being equal to).

# The expression returns the status of the evolution, so b=a means b should evolve into being equal to a.
# 3 = a + 3 means 3 will evolve into a + 3.

# So in this program:

(a = a) + 3 + 1

# (we use parens to group operators) means that a will either evolve with a + 3 or a + 1.

# So let's try to solve our problem. In order to count up forever starting from 1:

a = 1

# Great! We've set our initial value! Now we'll try to define what we should do in each iteartion:

(a = a) + 1

# The only possible evolving is by adding with 1. So what is our destination?

a | -1

# a must evolve into -1 by adding 1 forever, which is obviously impossible. Therefore this loops forever.

# Here is the full program (with printing):

a = 1
a | -1
p(a = a) + 1

Solve our equation

(3 + 4) = (x * (2 + 3))
p(x)

Add two numbers

# O only has one possible evolution method: input plus ord 'A'.
o=i+ord'A'

Compare two letters

# Possible evolutions of input:
(i = i2) | (p"Same"
q) | (p"Different"
q) # q is the quitting nilad
# If i is going to evolve into being equal with i2, print same.
# (The true symbol is defined to evolve into any symbol.)
# (However, the false symbol is defined to evolve into none of the symbols.)

# No evolution specifiers, so this prevents those values from evolving.

Golfed:

(i=i2)|(p"Same"q)|(p"Different"q)

Implementation(s)

I am currently trying to implement the language. The interpreter will be added as soon as possible.