Conversation

question for #Lisp users out there: what’s your workflow for changing the signature or return type of a function?

like let’s say I’m making a poker game and I have a (score hand) function, but then I want to have bonuses for different players, so I change it to (score hand player)

let’s say that there are a lot of calls to (score), because not only does the game itself use it in several places, but so does the AI to check hypothetical situations. that means that other functions’ signatures will have to change too, to incorporate player

what would your workflow be for doing this refactor?

I ask because I heavily rely on static analysis from my LSP for this type of refactor, but a lot of Lisp LSPs don’t seem to have the types of static analysis that I rely on (checking function arity, argument types, and return types), and I have a lot of trouble with the stack traces from languages like Racket (I think that might have something to do with tail call optimization and/or macros)

3
2
1

@kasdeya Using emacs + slime, you can use the slime "who calls" and "who references" capabilities to get a buffer of links to callers/referencers. `C-c C-w c ` by default for who-calls.

For me it's manual after that, but easy. Perhaps a keyboard macro if there's a lot to change.

Can't help with your AI question because I don't understand it. If you want static types and lisp, lisp may not be the best match for you, but you should check out Coalton if you haven't already. https://github.com/coalton-lang/coalton

0
0
1

@kasdeya So, why can `player` not be an optional argument? Why do you need to pass it through everything?

0
0
0

@kasdeya Which Lisp are you trying? The Common Lisp compilers I know give me warnings at compile time…

1
0
1

@pascal_costanza I specifically ran into this problem a lot with Racket. I did get runtime errors from my contracts failing, but unfortunately I had a really hard time reading the stack traces from those errors. I think something about the macros and/or tail call optimization was messing with the stack traces. that’s actually why I stopped using Racket - I was doing a refactor and it was so laborious that I gave up on the language unfortunately (even though it has an incredible thread macro system, and I also really like its contracts!)

1
0
0

@kasdeya I would recommend to try some other Lisps. Languages with s-expression notation are by far not all the same, just as languages with curly-brace notation are not all the same. I would especially recommend , but that’s just my personal preference…

0
0
1