freenode/#lisp - IRC Chatlog
Search
2:52:58
minion
The URL https://gitlab.common-lisp.net/users/sign_in?secret=ebc7a0f4 will be valid until 03:00 UTC.
9:45:24
decent-username
I'm right now writing a function with a #'macrolet inside. The question is: How can I access the arguments of the function that envelops the #'macrolet?
9:47:18
beach
If you mean the parameters of the function around the MACROLET, then you just write their names.
9:47:45
beach
But you can not do that at macro-expansion time, because the corresponding arguments are not available then.
9:49:03
beach
I need to go fix lunch for my (admittedly small) family. You either need to wait or see if someone else can answer.
9:51:58
decent-username
I'll try to solve the problem on my own. I'll let you know if I've managed to fix it.
9:56:17
MichaelRaskin
You don't need to unescape global-cell-x (the macro should expand to literally this symbol), and you do need to put comma before x (it is a macro argument that should be substituted in macro expansion
10:08:44
decent-username
my code compiles now. But the logic is still more broken than a 80year old who fell down a skyscraper.
10:44:47
beach
decent-username: It is conventional to put the loop keywords at the beginning of a line, not at the end.
10:45:38
decent-username
the commented block is the portion that gives me trouble: I get the following error message: "The value -1 is not of type SB-INT:INDEX"
10:47:28
beach
decent-username: Then you look at your backtrace, type a `v' in the frames, and look at what form is causing problems.
10:48:56
beach
It must be the case that global-cell-x or global-cell-y is 0, so that adding -1 to it gives -1 which you then use to pass to AREF.
10:51:17
beach
I always put (proclaim '(optimize (speed 0) (compilation-speed 0) (debug 3) (space 0))) in my .sbclrc
11:23:38
decent-username
It works! Here's the code I've written to the best of my current ability: https://gitlab.com/decent-username/undead-dungeon/blob/master/third-party/dungen/src/corridor.lisp
11:25:08
decent-username
I've modified mfianos Dungen library, because the created tiles don't contain enough information in order to decide which wall-sprite to use.
11:44:23
ECLIPSE
hi,would someone please help me to understand this lisp code,or beautifier it so I can read it,https://justpaste.it/3mr1e
11:46:11
no-defun-allowed
I think I will go with "no", since it's probably some kind of deobsfucation attempt at...AutoLisp or something like that? Some CAD scripting language.
11:48:31
no-defun-allowed
I think we'd need the actual file rather than trying to poke out strings out of it.
11:49:01
ECLIPSE
I am started studying lisp to understand ,,, and I was wondering about syntax ) ,,,, so I think its an advanced way to write lisp
11:49:07
no-defun-allowed
But, also "we" would have to be some other group, since this is a Common Lisp room and low-key AutoLisp is an unholy abomination.
11:49:40
no-defun-allowed
One of the things malware writers probably have in mind is to obsfucate their code, so I would not use it for learning unless you want to learn reverse engineering too.
11:49:42
decent-username
ECLIPSE: So advanced in fact, that it doesn't even qualify as a Lisp anymore.
12:09:39
ECLIPSE
@Bike , its AutoCad malware ,,,, it was obfuscated with spaces and /n /r ,, after I removed them I got this code ,,,,, but it still there is some points in code that I can not understand ,,, like first comment and the last one
12:25:09
decent-username
I'm about 90% sure ECLIPSE is a bot. If it now starts to talk to me, then that's even more suspicous.
12:36:15
beach
decent-username: Like I said, the convention is to put LOOP keywords at the beginning of a line rather than at the end.
12:38:44
beach
decent-username: Also, page 13 of the LUV slides by Pitman and Norvig has some interesting points. For instance, you should not use a non-Boolean variable in a position that "requires" a Boolean. So when you write (WHEN CELLS ...) you are violating this expectation.
12:40:47
beach
decent-username: And when you write (LET (RESULTS) ...) the message is that RESULTS is "uninitialized" and the person reading your code expects the variable to be assigned to before it is used. But you used it as if it were a list. In that case, you should write (LET ((RESULTS '())) ...)
12:47:14
beach
decent-username: Here is another one: WHEN and UNLESS should be used only in a context where the value is not needed. This expectation is violated when you write (LAMBDA (X) (WHEN (CARVED-P X) X))
12:49:28
beach
decent-username: In a context where the value is needed, use an IF with both branches. So, depending on the message you want to send to the person reading your code, either (LAMBDA (X) (IF (CARVED-P X) X NIL)) [if the value is a default value or a Boolean], (LAMBDA (X) (IF (CARVED-P X) X '())) [if the value is the empty list], or (LAMBDA (X) (IF (CARVED-P X) X 'NIL)) [if the value is the symbol NIL].
12:51:41
beach
decent-username: One more: Instead of writing (setf (cell-features (aref grid x y)) (cons ... (cell-features (aref grid x y)))) it is preferable to write (push ... (cell-features (aref grid y))). In addition, you then avoid multiple evaluations of (aref grid x y).
12:52:37
beach
But, especially, it is much more explicit, since it uses a construct that is the most specific that does the job. That's a general rule in programming. Use the most specific construct that will do the job.
13:00:44
beach
And if you decide to keep the recursive version, a recursive function should always be structured like a proof by induction, i.e. by handling the base case first. So it should read (if (null cells) nil (let* ....))
13:25:43
jeosol
beach: the energy was not wasted at all. There are others that read the code and learn from the style recommendation, how to write better code and design
13:27:27
jeosol
btw, I have a comment above: do you mean (when name ...) should only be used if name is some boolean, or like predicate
13:31:48
beach
This is also why we have two functions NULL and NOT that do the same thing. NOT takes a Boolean argument, whereas NULL takes a list or a default value.
13:33:03
jeosol
You heard about Grahams Bel lisp. What are your thoughts briefly. This is probably discussed here before.
13:34:12
beach
I haven't looked at it. I consider the introduction of new Lisp dialects unnecessary, and I don't understand the reason.
13:34:52
beach
By the way, it doesn't matter much whether we agree or not. Those two people are WAY more experienced than I am, especially when it comes to creating industrial-strength software written by a team of highly experienced professionals.
13:36:00
jeosol
I see, but could that effort not be put in improving the current one, especially if syntax or ideas is close to CL
13:36:56
jeosol
I did ask him a question on twitter a while back, when I started working on my application with CL using CLOS and someone mentioned I will have production issues. I asked him, he said he won't recommend CL at this (that) time but will recommend Clojure.
13:37:45
beach
I might recommend something other than Common Lisp as well, depending on the context. I don't think there is a general-purpose recommendation.
13:39:14
jeosol
which was not bad per see, but I was looking to write a large application, the image-based development probably got me to stick to CL in the initial phase.
13:40:18
beach
A language such as C++ is very hard to use for large applications. At least if you want your application to be both modular and fast. I often say that it is impossible to do that.
13:41:08
beach
The problem is the manual memory management. If your application is truly modular, you can not predict what references to objects might be kept by a particular module.
13:41:27
jeosol
Yes, that was the main issue I was having, layering the classes, organization packages, etc. It was getting difficult so decided to explore something else.
13:42:25
beach
So then, to keep modularity, the C++ programmers either copy everything or they resort to reference counting. Both of which are slow.
13:42:32
jeosol
I saw a CL code for a C/C++ code I wrote. Very concise and the easier to read and was doing more in a few pages that my massive C/C++ code base. The lisp code was for a genetic algorithm some guy wrote for his dissertation.
13:43:31
jeosol
Is there a technical name when a language is few syntax constructs to memorize? Saw something a while ago, but I can't recall
13:44:09
jeosol
I think this is what helps with my coding in CL. I often also have to work in python, pandas, numpy, and the argument keywords, changes here and there. It's hard to keep track and things aren't uniform
13:44:37
jeosol
with CL, I just focus on the application, know how things are structured, not a lot of mental burden.
14:19:14
Josh_2
beach: you wrote all that I am not completely lost xD Is this little snippet of code https://plaster.tymoon.eu/view/1518#1518 wrong? I don't understand