trash: initial planning ----------------------- workflow this project will take a long time to get anywhere near a satsfying point of completion, so if I want trash to be, well, not trash, I'll have to do things like optimization and tests at incremental points along the way. this development strategy surely has a name, but I don't know it. I'll define progress in terms of 'features'; once a feature is written in, tests will be written and optimization will be done. my hope is to use a ~~professional~~ tool like continuous integration for tests. non-language features - syntax highlighting - autocompletion - auto-detect when to do multiline input .. like in irb .. also do auto-indenting - readline shortcuts bash by looking at the language features of bash, it should be easy to design a minimum realm of functionality for trash to cover. important parts of bash: - invocations: `echo -s so sad rn` - comments: `# I have much to say` - interpolation: `echo "${variable}"` - variables: `name="phineas"` - substitution: `${name/a/x}` - slicing: `${name:0:3}` - length: `${#name}` - defaults: `${name:-"ariadne"}` - arrays: `arr=(a b c d)` .. with splatting/indexing/slicing - loops: `for x in arr; do ...; end` - ranges: `{a..z}` - built-in variables, eg $@, $#, $$ - conditionals (if/then/else, ||, &&, case) - piping: `ls -l | grep ".jpeg"` - input redirects: `ruby thing.rb < input.txt` - output redirects: `ruby screed.rb > save.txt` .. also stderr with 2> .. and stdout+stderr with > ... 2>&1 .. and appending with >> and its variants .. and getting file descriptors: `echo <(echo foo)` - functions - process stuff, like & and % syntax ideas? - the command line is a very horizontal place, .. so "block" statements should use {} .. braces, which are really good for nesting - again based on the medium, parentheses .. and commas are absolutely unnecessary .. when invoking commands - sigils are a good idea for semantic .. density and syntax highlighting - the types of sigils: .. + barewords = nothing .. + scalars = ~ (no $!!!!!) .. + maps = ` .. + lists = ^; * to splatter .. + processes = % - operators .. > to, < from, plus bash-style appends .. 2> replaced with >! .. > .. 2>&1 replaced with >!! .. pipe works like normal .. =~ for regex matching .. # and #{} for interpolation - comments start with ;; - lines are separated with ; - special trash operators start with @ .. used for stuff like math -- @add, @sub .. length of strings/arrays done with @l - definitions use =: `foo = 2` .. spacing between `=` isn't significant! - primitive datatypes: flint, str, process .. 'flint' = float that gets automatically .. coerced into an int when needed example ;; respond to arguments/user input echo -n "what's your name? "; read name; ;; fn with default param greet name: "world" -> { if (@eq ~1 "hi") { echo "hello #~name!"; } elsif (@eq ~1 "bye") { echo "goodbye #~name."; } }; ;; fn with splat greets *names > { @map greet ^names }; greet ~name; names = ["larry", "evergreen"]; greet ~names[0]; greets ^names; ;; lambda @map { name -> echo "#~name is my friend"; } ^names; ;; processes pid = loop { loop {} }&; pkill %pid; ;; a map map = { name: "lonerism", genre: "sad" }; genre = `map["sad"];