nobody-famous / alive

Common Lisp Extension for VSCode
The Unlicense
203 stars 19 forks source link

Might not be an issue, might be #42

Closed cooleynal closed 3 years ago

cooleynal commented 3 years ago

This is on a database supporting the commands.

When the following commands are entered in the REPL: (filter '(1 3 -9 5 -2 -7 6) #'plusp) (filter '(1 3 -9 5 -2 -7 6) #'evenp)

swank server disconnect.

However when the same lines are in the database, and then put into the REPL, the swank server is well behaved.

So (funcall ...) lets us pass functions as parameters? Is this that homoioncity people were talking about?

nobody-famous commented 3 years ago

Can you grab the last emacs-rex command? I can't seem to recreate the disconnect. I used the standard equivalent of filter, which is remove-if-not, and it worked fine.

Funcall is for explicitly calling a lambda, like doing callbacks in JS or Python. Homoiconicity refers to the code being lists, so you can use the list functions to create new code. That's what macros do.

It allows you to modify the syntax if you want. The loop macro is an example of a macro creating a new syntax that doesn't conform to the rest of the language. Lisp does't have a true switch statement. Cond, case, et al are macros that generate nested if statements. Since macros are compile time, the compiled code is the same as if you had written the expanded version by hand.

cooleynal commented 3 years ago

I swear recreated the fault about ten times before posting. Reevaluated the file a few times to (so i thought) Unfortunately I can not recreate it now. Feel free to close me.

How did you get so good at all the programming languages?

I see lambda come up a lot. I used lambda expressions in java for anonymous classes and starting threads. Is this anything close to a calling a lamda here?

nobody-famous commented 3 years ago

Eventually you realize that the languages are mostly the same, so going from one to the other isn't that different. They each have their features that make them unique, but that's generally a small percentage of what you need to use the language.

I should've used a different term than lambda. A lambda is an anonymous function, meaning it's not bound to any name. When a function takes another function as a parameter, there needs to be some way to call it. With other languages, you put parentheses after it. If you have an argument foo, then foo() will treat it as a function and try to call it. Lisp doesn't have that sort of syntax so funcall is used instead.

In your example, you could replace #'plusp with (lambda (item) ...) and have it return t or nil based on whatever criteria. That way you could filter the list however you want.

nobody-famous commented 3 years ago

I think I figured out what's going on with the disconnect. If there's a non-ASCII character after the pound sign, swank is bailing out. It's going to the debugger in Emacs, so I'm going to try to figure out what it's doing differently.

nobody-famous commented 3 years ago

Looks like I wasn't UTF-8 encoding the strings. Should have a fix up tomorrow, or Monday at the latest.

cooleynal commented 3 years ago

Oh dont get me wrong, i did throw a few errors with copying and pasting and use of ' (the bad one), this was different for sure.

Thanks, highly appreciated.

nobody-famous commented 3 years ago

I put a new version up with the UTF-8 fix. If you still see it dropping connections, reopen this one or open a new one.

cooleynal commented 3 years ago

You are the embodiment of a greek god.