phanthero
2020-11-19 23:45:48

Do you folks use var-1 or var1 . Can’t figure out the convention here lol..


sorawee
2020-11-19 23:49:38

I think they are both OK, but also equally rare. Usually you will see X and X*, not X-1 and X-2. It’s also better to avoid suffixing with number and just name it meaningfully, like left-node and right-node, rather than node-1 and node-2.


sorawee
2020-11-19 23:50:24

The PRs in racket/racket just reached this milestone.


phanthero
2020-11-19 23:56:05

My use case is an n-ary tree, where I want to do something special with child #3, child#5 and child #10


phanthero
2020-11-19 23:56:32

Would the convention here be to do child, child* and child**?


sorawee
2020-11-19 23:57:24

Well, is there meaning associated to child 3, 5, and 10?


jcoo092
2020-11-20 00:01:19

If you have more than a small handful of related variables, why don’t you use some sort of collection for them? :confused:


phanthero
2020-11-20 00:08:34

Take this example: We have the sentence, with each word stored in a vector for easy constant time access: “Racket was made by the PLT team”. Now, there are three types of things here: 1. verbs: was, made 2. nouns: Racket, PLT, team 3. grammar-stuff: by, the I know exactly where the nouns in this sentence are going to be. They will always be at indices 0, 5 and 6. I want to add them to a dictionary. So they are all “nouns” where I will do the same thing to them, i.e add them to my dictionary (this is just an elaborate example). So yes they are related I guess, but I want to preserve the original order with the verbs and grammar-stuff, so I’m not using a collection. Right now I’m suffixing the number such that we have noun-1, etc.


phanthero
2020-11-20 00:16:44

The sentence in this case will be the right hand side of a production rule for my language


phanthero
2020-11-20 00:17:01

I want to recurse on the non-terminals, which will be at specific locations


phanthero
2020-11-20 01:14:20

Would it be possible to add vi key bindings in the command line racket REPL? The ipython (command line python interpreter) has this, and many people wanted it as well it seems: https://stackoverflow.com/questions/10394302/how-do-i-use-vi-keys-in-ipython-under-nix

I have vi keybindings enabled with readline, and have also modified my ipython_config.py (in the Stack Overflow answer above) to have vi keybindings. So I have vi keybindings in both bash and ipython, but I don’t think there’s an option for Racket lol..


willghatch
2020-11-20 04:28:23

The Racket REPL just uses libreadline, so you can configure your ~/.inputrc file to use the same bindings as other readline-aware programs.


willghatch
2020-11-20 04:30:05

Well, I should be more specific: by default it uses libedit, which is a reimplementation of libreadline that is worse but not GPL licensed. You can also install the readline-gpl racket package (raco pkg install readline-gpl) to use libreadline instead, which solves a lot of problems, especially with unicode.


phanthero
2020-11-20 05:16:44

Thanks!! Installing readline-gpl automatically gives me vi bindings since I had already set set editing-mode vi in my ~/.inputrc file! I totally thought Racket didn’t use readline, which would have explained this discrepancy of ~/.inputrc not working, but I guess they were using a similar enough thing.