freenode/#lisp - IRC Chatlog
Search
15:14:43
khrbt
myrkraverk: I have been sitting on this for a while. https://github.com/khirbat/linedit.git
17:41:07
stacksmith
Greetings. Need advice: at the end of my function I call a function that returns multiple values. I need to add an extra value at the end. Is there a way of doing that without m-v-b and a new values form?
17:42:50
Bike
i guess you could do (multiple-value-call #'values (call) other-value). but i would rate this as pretty weird
17:46:23
stacksmith
Since all this is happening at the end of the function, I thought there may be some magic way to append more...
19:51:22
fourier
also a question about asdf and quicklisp: if I have a system specified in defsystem-depends-on, and perform ql:quickload of my system, the system defined in defsystem-depends-on by some reason is not downloaded by ql
19:53:25
Bike
is (defstruct foo foos1 (foos2 foos1)) legal? i thought it was but now i think i was mistaken
20:04:00
sjl
> The symbols which name the slots must not be used by the implementation as the names for the lambda variables in the constructor function, since one or more of those symbols might have been proclaimed special or might be defined as the name of a constant variable.
20:05:03
sjl
If you're expecting foos2 to have an initform of foos1, and that that would evaluate to the keyword you passed for foos1, I think that bit of the spec explicitly forbids that
20:08:53
sjl
interestingly, sbcl and ccl DO use the symbols as the parameter names if you specify a BOA constructor
20:16:23
fourier
please recommend some simple documentation generation system from CL sources. I need something what can extract docstrings from functions and generate github markdown document. could write something myself but maybe something exists already
20:20:39
rme
I'm not trying to tell you what to do, but one option would be to write actual documentation, rather than fiddling around trying to generate it from docstrings and introspection.
20:21:22
Bike
the page on defstruct says the initforms are to be evaluated in the lxeical environment of the defstruct, which pretty much forbids that
20:21:51
sjl
Bike: yeah, I don't think that can work for the keyword constructors because they're supposed to use other symbols as the lambda arguments
20:26:46
sjl
> If no default value is supplied for an aux variable variable, the consequences are undefined if an attempt is later made to read the corresponding slot's value before a value is explicitly assigned. If such a slot has a :type option specified, this suppressed initialization does not imply a type mismatch situation; the declared type is only required to apply when the slot is finally assigned.
20:35:43
Bike
new question. if the clhs defines a function can an implementation have it be a generic function instead?
21:04:10
k-stz
hey, I try to parse a formula like !A and generate ==> (not A). I'm stuck on how to approach this, do I use READ-CHAR or just convert it to a string? Problem arose when trying to parse formulas like: !(a -> b)
21:23:50
stacksmith
k-stz: suggestion: make sure you understand Lisp pretty well before attempting to implement a compiler for another language. Otherwise you will be in a world of pain. You must pay special attention to the CL reader and its limitations, symbols and packages (in terms of how your syntax maps to CL)...
21:26:17
stacksmith
Another suggestion: unless you really need a different syntax, stick with Lisp and save yourself a lot of trouble.
21:32:24
k-stz
stacksmith: thanks, I wanted to try a simple parser in lisp because I never tried it and hope to learn something. That felt like a good starting point
21:37:23
stacksmith
k-stz: I do not mean to discourage, but I speak from personal experience of trying to do something similar when I started with Lisp. It seemed like an easy enough task, but led to a serious smack-in-the-face realization of just how pathetically ignorant I was at the time. It was a great experience but your appreciation of such things may be different.
21:43:52
k-stz
stacksmith: I think I see your point, this already isn't as easy as a thought. No damage done, though. Seeing the first few problems makes me attentive to solutions, and I just might know where to look next
21:46:51
stacksmith
k-stz: Another observation is that you can do it in a Lispy way, by using the Lisp reader, macros, etc. or by parsing text, the way you'd probably do it in C or whatnot. You will learn entirely different things. Lisp is great for writing DSLs, but it is not a task for a novice.
21:51:05
stacksmith
k-stz: Read 'On Lisp' - it is full of useful information about doing things like that, including an entire Prolog implementation in a few pages of code, and information about reader macros and regular macros.
22:01:18
k-stz
stacksmith: I have this book on my radar, I should also encounter this topic again in SICP soon. Thanks again o/
22:05:13
k-stz
I found what I read about Erik Naggum enjoyable as well, I'd say because he can articulate his opinions well and he touches on many things. It doesn't appear shallow
22:06:04
Shinmera
While his writings are very insightful, they definitely often are inflammatory as well though.
22:09:35
stacksmith
I learned a tremendous amount when I started out - by reading Naggum transcripts. It was never boring, although somewhat painful on occasions.
22:11:36
dim
https://tapoueh.org/blog/2018/03/object-relational-database-management-system/ if you're interested, comparing PostgreSQL type system / function overloading with CLOS generic functions
1:18:32
Bike
you put the defun in your repl, and then the next line try to call it, and it doesn't work?
1:24:52
Bike
gethashes is a function that gets a value out of some hash tables. it has no provision for writing into hash tables
1:25:07
Bike
there is no way for the compiler to look at your loop and figure out an inverse procedure, see?
1:26:28
Bike
it analyzes the form (gethash key table) and macroexpands into something that writes into the table.
1:29:50
Bike
you can also try (macroexpand-1 '(setf (gethashes foo "two") 2)) to see why that didn't work out.
1:34:40
Bike
if you're still thinking about pointers, keep in mind c has lvalues as a distinct concept. you can't get the address of a register variable but you can assign to it no problem.
1:36:10
jasom
johnnymacs: you know how you can doo foo[bar] = baz in C, in this case SETF is like the = and gethash is like foo[bar]
1:37:21
Bike
you can do (incf (gethash foo bar)), for instance, to increment a value in a hash table
1:38:08
stacksmith
johnnymacs: unlike forth, where cells are pointers and @ and ! read and write to them, in Lisp mentioning a variable fetches it by default. setf sets it. setf can set a lot of complicated forms like gethash. You can also write a function to let setf know what to do with your gethashes.
1:53:08
Bike
so, lisp has assignment, but it is not pointers, and it is not "hacked to behave like pointers" or whatever
1:54:22
Bike
they aren't! all you're trying to do is set values in a hash table! that is easy to do with setf gethash, you just want to deal with pointers instead for some reason
1:55:19
Bike
yeah, and you already wrote that. now you just need to write a (setf gethashes) that does a loop the other way or whatever.
1:56:48
johnnymacs
If I am going to modify setf to handle gethashes the only way I can do that is with an array/hash table of functions or nested conditionals
1:58:04
Bike
this gethashes thing, it's defined so that (gethashes table a ...) = (gethashes (gethash a table) ...), right?
1:58:41
johnnymacs
Well what happens to the speed of setf as the number of cases setf can handle increases
2:01:12
Bike
(setf (gethashes table ...) new-value) will expand into (funcall #'(setf gethashes) new-value table ...)
2:02:02
Bike
of course, for most uses i imagine the number of keys will be fixed, so you could write something to do it without a loop
2:21:01
stacksmith
johnymacs: it's great that you jumped in and are coding, but you have a bit of a learning curve. Rather than fighting it, you need to get to the point where CLHS makes sense. Also not bitch that CL is getting in your way. It is your brain that's in the way of accomplishing tasks, not CL.
2:25:01
stacksmith
Bike's code should pretty much to the basics. Also read about Lisp macros - I think you may not fully appreciate them. They are kind of like Forth immediate words - they run at compile time and transform the code to your wishes.