freenode/lisp - IRC Chatlog
Search
15:57:04
beach
JuanDaugherty: Xof just arrived. You can ask him more about SBCL CLOS if you need to.
15:59:09
afidegnum
hello, please can anyone help me understand this about Macros? https://ghostbin.com/paste/v355s when do we use quote and comma? if i understand well, Quote is equivalent to EVAL in some languages, right?
16:02:16
beach
afidegnum: The simplest way to see the backquote facility is to consider it to be a quote, EXCEPT that if some nested stuff is preceded by a comma, than that stuff is evaluated.
16:04:17
beach
afidegnum: So in your paste, the result is a list (* x y) where x is the value of the parameter VALUE and y is either 1, 60, 3600 etc., according to the value of the parameter UNIT, which is presumably one of the symbols s, m, h, d, ms, or us.
16:05:38
beach
Anything inside a backquoted form that is not preceded by a comma is never evaluated.
16:07:06
afidegnum
while reading notes on letoverlambda, there is a preceding function, sleep unit, (sleep-units% 2 'm)
16:07:56
beach
If sleep-units% is a function, its arguments are evaluated before the function is applied.
16:09:36
beach
Like I said, the arguments to a function are evaluated before the function is applied.
16:10:18
afidegnum
aaah, wait, does it mean it mean it would have generated a variable not found error if (m) was rather used?
16:11:09
beach
If you had said (sleep-units% 2 m) then you would have gotten an "unbound variable" error.
16:11:54
beach
The parameter UNIT is a variable inside the function and the value of that variable is the value of the argument that was passed when the function was called.
16:13:15
beach
In which case, the value of m is the symbol s. so sleep-units% will be called with the number 2 and the symbol s.
16:13:19
afidegnum
i haven't tried a failed call yet but i wanted to understand the rational behind the (un)quoted variable/symbol
16:19:24
malice
Hey, I haven't wrote any macro in a long time and now I'm struggling with what seems to be pretty easy.
16:19:52
malice
I want to write QLIST macro so that (qlist (1 2) (3 4) (5 6)) == (list '(1 2) '(3 4) '(5 6)). Is this possible?
16:21:34
afidegnum
even though i m not good in macro yet but i think with this, you pair quote and loop the sequence range. am i correct beach ?
16:25:09
afidegnum
beach: sorry for disturbing again, even though i read it last week but can you please help clarify the difference between '# &body &rest ,@ letargs
16:26:36
beach
afidegnum: &body and &rest are the same. They define a parameter that will hold a list of all remaining arguments (after all the required arguments have been bound to their respective parameters.
16:28:27
beach
afidegnum: ,@ is a "splicing unquote". If you do `(a b ,(list 1 2) c) you get (a b (1 2) c). If you do (a b ,@(list 1 2) c) you get (a b 1 2 c).
16:31:40
beach
#' is known as a "reader macro" Not an ordinary macro. When the READ function sees #'bla, it returns a list (function bla). It is analogous to ' which is also a reader macro. When the READ function sees 'bla, it returns the list (quote bla).
16:34:17
beach
Presumably, the argument to the macro is something that looks like LET bindings, like the list ((x 10) (y 20) (z 30)).
16:35:11
beach
&rest is not a parameter. It indicates that the parameter BODY holds a list of all arguments except the first two.
16:36:01
beach
So if you call NLET like this (nlet bla ((x 10) (y 20)) a b c d) then the value of BODY will be the list (a b c d).
16:38:14
beach
afidegnum: I need to go cook dinner. I'll leave you in the capable hands of other #lisp participants.
20:52:17
krwq
Bike: so i.e. if you got a list of something which has a form let's say: ((:name "a" :foo "bar") (:name "b" :foo "asd")) - what's the best way to i.e. find something with name x (if doesn't exist then create and add new one) and modify field :foo into y
20:52:51
krwq
i wrote function which does that but i think i slightly overcomplicated as the code seems to be too long for such simple thing
20:54:33
Bike
(defstruct thing name foo), then (let ((result (find "x" list-of-things :key #'thing-name :test #'string=))) (if result (setf (thing-foo result) "y") (push (make-thing :name "x" :foo "y") list-of-things)))
20:55:45
afidegnum
hello, i m reading about clack, lack and woot web but there is no deep down documentation. anyone ever used them?
20:56:32
Bike
geez, given how much trouble i've had with git submodules i don't know if i can even say much
20:56:36
krwq
Bike: i'd rather keep it as a lisp tree as it is more flexible and i do not want to define all structs since i dont know them
20:58:57
krwq
if there exists a folder on my disk which is not a local repo it should automatically create a repo, and check if on my github account there is a repo with such name
21:01:13
Bike
I don't think I understand the problem very well, but the most basic thing is to avoid using list manipulation functions directly.
21:01:30
krwq
also each of this repos should be detected if it is lisp repo and if it is it should update .gitignore file if it isn't properly set
21:01:59
Bike
like, if you stick with your list-of-plists, you should have (git-name plist) rather than (getf plist :name). then you can swap the underlying representation more easily later.
21:06:45
krwq
i never know if i should use (with-slots) everywhere or rather prefer some accessors or maybe some other way
21:08:49
aeth
classes = general stuff; structs = if you know the types, and the types will never change, and you want/need them to be fast; arrays = use them like structs the numbers are all the same non-bignum type and you are okay with numerical indices (most implementations will support most arrays of non-bignums and the rest will just treat them as regular arrays)
21:08:49
krwq
Bike: i do not care about it when i represent program in form of code. after im finished and stuff is slow i wonder how can i not change the logic and still make everything fast - then i update my tooling
21:09:24
Bike
yeah, that's the basics, like i said you use accessor functions instead of getf or whatever directly. and don't worry about performance while you're putting it together.
21:09:36
aeth
and then of course there are simple vectors (that hold everything) and lists and strings, but those are fairly obvious in use cases.
21:10:13
Bike
one thing i do is just start writing out high level functions in terms of a nonexistent lower layer, and then i write the lower layer to fit whatever was convenient above.
21:10:29
krwq
compiler should figure out if it should use conses behind or plain continous block of memory
21:11:02
aeth
The tricky, non-obvious stuff in CL are hash-table vs. plist vs. alist and also... set representations. The built-in way to represent sets as lists is... not great. Probably the worst way of doing sets.
21:11:39
Bike
doesn't matter if it's nearly impossible, you know? that's the kind of decision a human programmer could go back and forth on for various subtle reasons, a stupid computer has no chance
21:11:46
aeth
Oh! Also, CL has two built-in ways to do stacks (via vectors and lists), but if you wanted to do queues via either, you'd have to put in some work, too. (Or use a library.)
21:12:58
aeth
For the most part, CL's sequences, plists, alists, and hash-tables are sufficient. As I said, there are at least two built-in ways to do stacks. It's just (for the most part) queues and sets that are missing (unless you want sets-as-lists, which you shouldn't except for very tiny sets)
21:13:02
krwq
you have maybe few choices - optimizer could try each possible data structure and check which one works best
21:13:57
Bike
mm, there have been compilers that tried to do such things since fortran. hasn't really been that popular.
21:15:04
Bike
the thing is that it takes an enormous amount of effort from the compiler programmer, a pretty big amount of effort from the compiler, and in the end it's probably still slower than if a human spent five minutes guessing. diminishing returns and all
21:15:27
aeth
krwq: It would be much, much better just to have a generic interface on top of indexable data structures (sequences and n-dimensional arrays where n =/= 1 and hash-tables and plists and alists, etc.) and then it would be easy for you to refactor the code later if your needs change.
21:16:22
krwq
aeth: if this is the simplest implementation - i do not care if i use generics function or a macro as it will do its job
21:16:46
aeth
I think the issue is that there's no way to add this to CL portably afaik without a performance cost.
21:17:00
aeth
And the people who care about switching data structures to avoid performance issues will want to avoid that, too.
21:17:54
krwq
you could make it so that you run the program for a minute it will pick best settings and compile itself permanently wuith it
21:18:59
Bike
ah, if you're intested though you should help me with compiler dev in your spare time. i don't mind sky pies.
21:20:05
krwq
i do want to do the git stuff, i have some pieces written already but there is plenty of work left
21:20:58
krwq
i will scope myself to what i need i gues but will try to keep logical order in case i will plan to finish the whole thing one day
21:31:13
jfe
i know this isn't #emacs, but has anyone seen the following error when launching SLIME?: READ error during COMPILE-FILE: The symbol "HOST-ENT-ADDRESS-TYPE" is not external in the SB-BSD-SOCKETS package.
21:32:50
Bike
http://stackoverflow.com/questions/42760607/slime-he-symbol-host-ent-address-type-is-not-external-in-the-sb-bsd-sockets-p and you're not alone (unless this is you)
22:05:47
aeth
Clearly, the solution is to make integers sequences and get rid of bit-vectors altogether.
22:07:15
pjb
Why do you say that? Bit-vectors are very nice. Also, there are bit arrays for those nice bitmap display and graphics.
23:04:25
aeth
Xach: that's why I did this: https://gitlab.com/zombie-raptor/zombie-raptor/blob/027c20ae395cede0443f58372890264fd3a2750a/math/boolean-set.lisp
23:04:49
aeth
Now, I'm not doing cryptic logical operations on integers. Instead, I'm doing set operations on something I called a "boolean set"
23:06:32
aeth
I actually caught iirc two logic errors by moving to set theory because it became very clear exactly what I was trying to do.
23:08:36
aeth
Also, I found that I was using subset a lot of the time when I could also just be checking for membership.
23:10:32
aeth
I could probably add two more variations, one that operates on &rest instead of two items, and one that doesn't have an upper size limit but is potentially less efficient.