itty

Sean's Itty Bitty Programming Language
git clone https://code.literati.org/itty.git
Log | Files | Refs | LICENSE

README.markdown (3053B)


      1 Itty
      2 ====
      3 Sean's Itty Bitty Language
      4 
      5 Itty is a stack-based language with single-character words, inspired
      6 primarily by False and Mouse.
      7 
      8 Examples
      9 --------
     10 
     11 hello.itty is the classic hello world.
     12 
     13 pi.itty is an unbounded pi spigot; it will print the digits of pi
     14 until the cows come home. IMHO this is a much better hello world for
     15 this language; it's actually why I developed Itty in the first place.
     16 
     17 
     18 Variables
     19 ---------
     20 
     21 Currently there are 26 global variables represented by the ASCII
     22 capital letters, and 26 local variables represented by the ASCII
     23 lowercase letters. This will change: I intend to implement nested
     24 scope and allow all 52 variables to exist in any scope.
     25 
     26 Variables are set with :<variable letter>, fetched by typing just the
     27 letter. Functions stored in variables will be evaluated rather than
     28 being put on the stack; to actually put the function on the stack use
     29 ;<variable> (not yet implemented).
     30 
     31 To set a bunch of variables at once, enclose the names in single
     32 quotes, for example: 'abcd' will pop d, then c, then b, then a. This
     33 makes it a lot easier to read and write functions that take multiple
     34 arguments, since it's traditional to put arguments on the stack in
     35 reverse order.
     36 
     37 
     38 Blocks
     39 ------
     40 
     41 Blocks are created by enclosing code in square brackets
     42 ([ and ]). Call a block unconditionally with ! or conditionally with
     43 ?. ? Takes three arguments: a boolean (0 for false or nonzero number
     44 for true), a true case block, and a false case block. To leave one out
     45 just use an empty block. To execute a tail call, make sure the ? or !
     46 comes right before a ]; whitespace will break the tail call detection
     47 code (this is a bug).
     48 
     49 
     50 Input
     51 -----
     52 
     53 There is no input right now. Suggestions welcome.
     54 
     55 
     56 Output
     57 ------
     58 
     59 Comma (,) will print the ASCII character corresponding to the number
     60 on the top of the stack. Print a newline with 10, or a tab with 8,. To
     61 print a string, enclose it in double quotes. Strings may eventually be
     62 first class, so this may change. There is no escape character; to
     63 print double quotes use 34,.
     64 
     65 Period (.) will print the object on top of the stack, with no newline.
     66 
     67 Math
     68 ----
     69 
     70 Numbers are represented by sequences of decimal digits. Only positive
     71 integer constants can be represented. To put a negative number on the
     72 stack, subtract from 0 or use the unary negation (_) operator.
     73 
     74 Only integers are supported; they are implemented as bignums using GNU
     75 MP. Addition (+), subtraction (-), multiplication (*), floor division
     76 (/), and modulo (%), and unary negation (_) are supported. Other
     77 popular math functions that would be too slow to implement in Itty
     78 will eventually go into a math module once I have modules.
     79 
     80 
     81 Booleans
     82 --------
     83 
     84 Nonzero represents true; zero represents false. Operations are unary
     85 not (~), binary and (&), and binary or (|). I may add xor in the
     86 future using ^, which is currently the trace operation, and move trace
     87 to a debug module once I've implemented namespaces.
     88 
     89 
     90 Debugging
     91 ---------
     92 
     93 There is currently only trace (^). Eventually debugging functions will
     94 get their own module.