Keg+ Language Design

From Esolang
Jump to navigation Jump to search

Hey, so I thought I'd go and show you all the planned features in Keg+.

Inherited from Keg

Command Description
a-Z Autopush char
0-9 Autopush number
[...1|...2] Pop top, ...1 if true, ...2 otherwise (if given)
+ - * / % Pop x and y and push y <op> x
: Dup top
! Push length of stack
' " Left/Right shift stack respectively
~ Push random number between -inf and inf
@name n|...@ Define function n as ...
< > = Less than, greater than, equals
\ Escape next symbol
? Get input from the user
, Print top of stack
_ Pop top of stack
$ Swap two top elements

Inherited From Keg But a Bit Different

Command Description
{...1|...2|...3} While loop (pre/post-test based on ...2 [if given]). Condition ...1 or `1` , code ...3
(...1|...2|...3) For loop: for ...2 in ...1: ...3
. i2. -> x[i1][i2] .i1|i2…in. -> x[i1][i2]...[in]
& Standard Sequence Library reference (SSL)
`...` String!

Completely New

∆ means that I haven't decided the symbol yet

Command Description
ß Eval/exec top of stack
¶...¶ String!!
‘...‘ String!!!
“...“ String!!!!
«...1|...2« String!!!!!
„...1|...2„ String!!!!!!
...1»...2 Inclusive range from ...1 to ...2
...1…...2 Exclusive range from ...1 to ...2 (i.e. ...2 not included)
∆name Set variable name to top of stack (see point 1) Maybe use the λ symbol, as the simplest lambda function is the identity function.
∆name Get variable name's contents (see point 1) Maybe use ®, standing for "retrieve".
∆name Call function name (see point 2) Possibly ©, standing for "call".
Dictionary (see point i)
Square root top
Assign index (see point 3)
§ Raw print top of stack (see point ii)
∆...∆ Special compression (see point 4) Maybe use ←, because the compressed string is smaller than the original string, and the < sign is already taken
∆id Access pre-defined constant (see point 5) ₳, standing for "Access"

Unsure Symbols

  1. I was thinking either £ for set and ¥ for get or # for set and ; for get. Examples: (Both programs take two numbers and add them together)

    ?£n?£m
    ¥n¥m+,

    or

    ?#n?#m
    ;n;m+,
  2. Yes, I know that originally calling functions was supposed to be like @...@, but I was finding it hard to implement that, so I was thinking maybe another character might work (not sure what yet). Maybe the $ could be repurposed for this (and just not have swapping).

  3. What's the use of having indexing if you can't assign an index. This symbol would assign something to the item specified. Perhaps º would be good. E.g.

º...1|...2º
  1. Some sort of filled in circle would be nice here, but if it would make sense to have something else, I'm fine.

  2. Maybe have to access predefined constants (e.g. ∑T would push, say, 1,000).

  3. This would scan from the number after the symbol and go until a non-number character is reached. Could be .

Clarifications

Point i

•key|value;key1|value1;key2|value2;•
{key: value, key1: value1, key2: value2}

•key1;key2;key3|chars•
{key1: chars[0], key2: chars[1], key3: chars[2]}

•chars|key1;key2;key3•
{chars[0]: key1, chars[1]: key2, chars[2]: key3}

•chars1|chars2•
{chars1[0]: chars2[0], chars1[1]: chars2[1], chars1[2]: chars2[2]}

Point ii

Rather than printing the top item nicely (converted to a nice looking string), print the item raw as if __repr__ was being called.