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* ....))