freenode/#lisp - IRC Chatlog
Search
9:10:17
pjb
reepca: (defvar *foo*) (defun foo (&rest args) (apply *foo* args)) (defun g () (foo 1 2 3)) (let ((*foo* (lambda (&rest args) (reduce '+ args)))) (g)) #| --> 6 |#
9:10:41
ck_
Shinmera: you're running irclog.tymoon.eu, is that right? Are you open to a small feature request?
9:11:55
ck_
I'd sometimes like to switch channels at or around the timestamp I'm currently looking at
9:14:21
pjb
White_Flame: it has probably bit-rotten a little, since I don't use it anymore. Putting dependencies in asd files is better.
9:14:34
Shinmera
I could maybe turn the channel header into an option list instead to do the switching. I'll think about it.
9:14:45
ck_
well, the first thing I looked for was a time input field at the channel view, to navigate to a point in history that way. I'll just add a bookmarklet to get there quicker
9:14:50
pjb
White_Flame: but the principle applies: scan the files to build the dependencies yourself, and generate an asd file.
9:15:42
Shinmera
ck_: The software running is open source too, so if you have time you could have a go at fixing it yourself. https://github.com/shirakumo/chatlog
9:17:18
Shinmera
Time input did exist in a previous version, but it became too cluttered, especially for mobile, so I removed it in the streamlining process.
11:10:22
boeg
So I'm trying to figure out how systems and packages works, and I've created a package.lisp now and a *name*.asd. Now, I normally just use sly in emacs to run my common lisp and manually use quickload to load libraries, but now I have defined a dependency in the asdf file, so my question is, how do I use this in sly so it takes care of loading things defined with asdf?
11:12:33
pjb
boeg: systems define a set of files, and their dependencies, so that asdf can compile and load them in the right order.
11:13:18
pjb
boeg: those files may contain in-package forms, so that their symbols are interned in those packages.
11:13:49
boeg
So package.lisp contains defpackage and then in a another file i have an in-package call for the package defined in package.lisp
11:13:58
pjb
boeg: this may be packages defined in a file of the system, or not. You could (defun cl-user::foo () 'foo) thus defining a function named by a symbol interned in the cl-user package, for example.
11:14:40
pjb
boeg: so if you want to define your own packages, and put them in a package.lisp file, this file needs to be loaded before the other files are compiled or loaded, so their in-package forms will find the packages you defined in the package.lisp file.
11:14:58
pjb
So for each file, you will have a dependency such as: (:file "foo" :depends-on ("package" …))
11:15:46
pjb
boeg: remember, asd files are just like Makefiles, they define dependencies between your files (and also with other systems).
11:16:09
pjb
boeg: this is a system dependency. You define it with :depends-on in the defsystem form.
11:16:41
pjb
Once this dependency is established, your files can access directly anything that is defined by those systems, since they will have been loaded before the current system.
11:17:14
pjb
boeg: if you make your asd systema vailable to quicklisp (eg. putting them or a symlink in ~/quicklisp/local-projects/ ) then you can just use quicklisp for your system like for the others.
11:17:33
pjb
The advantage of using quicklisp, is that if you're missing a dependent system, quicklisp will download and install it automatically.
11:18:19
boeg
oh, so I make a symlink in ~/quicklisp/local-projects/ to my .asd file that has a dependency on split-sequence
11:19:05
pjb
No need to loald the .asd file directly or any other file. quickload will do everything.
11:20:33
boeg
pjb: does it matter how deep the .asd file is relative to the symlink? Could I for example symlink to ~/projects where the .asd file is in ~/projects/../*.asd ?
11:21:29
pjb
in some cases, quicklisp doesn't discover them immediately. You can force it with (ql:register-local-projects)
11:25:20
boeg
I load my system, seems to be fine, then I load a file I'm working on and call a function just like (my-function) which usually works but now it doesn't
11:26:13
pjb
You must use the name of the function, which is a symbol interned in some package. You need to know this package.
11:26:42
pjb
If you have a in-package form before the form where the name of the function is interned, then it's interned in that package.
11:26:47
boeg
so the package is named ... well i have (in-package :aoc2019.day06) at the top, and function is called day06
11:27:47
pjb
perhaps you exported "DAY06" from the package named "AOC2019.DAY06", in which case you can use: (aoc2019.day06:day06) or (use-package :aoc2019.day06) and (day06)
11:28:50
pjb
For example, you could define a asd system aoc2019 dependent on all the aoc systems, with a aoc2019 package that would use all the aoc2019.day?? packages, so that (in-package :aoc2019) you could call directly all the (day01) .. (day31) functions.
11:29:07
boeg
something is weird though, if I remove the "in-package" and do as I use to, my function gives one result and if I go about it with asdf and so on, call it with (aoc2019.day06::day06) it gives a completely other result
11:29:36
pjb
boeg: if you're lost you can use (let ((*package* (find-package "KEYWORD"))) (apropos "day")) to find what package the day symbols are interned in.
11:30:04
pjb
boeg: your functions may depend on the run-time package if they use READ or INTERN etc.
11:30:27
pjb
boeg: it's not a good idea in that case to let the run-time package up to the user. You would have to bind the *package* at run-time.
11:31:49
pjb
You may also depend on other variables such as *print-…* or *read-…*; you can get a specific setting with (with-standard-io-syntax …) or otherwise code to avoid depending on them, or set them to specific values.
11:32:12
pjb
For example, (setf *read-base* 8.) or (setf *read-base* 16.) could break a lot of program using numeric input…
11:32:50
boeg
but I don't understand ... How are are the functions loaded differently depending on if I use asdf or just manually load my .lisp file?
11:32:58
pjb
If your specifications specifies base ten, then your program should contain a (let ((*read-base* 10.)) … (read) …)
11:34:09
pjb
boeg: they're not loaded differently, they're loaded with load, in the current *package* and *readtable* by default. Perhaps asdf sets the current *package* to something specific different than your current *package* in the REPL, but it's up to your files to contain in-package forms to specify which *package* must be used to intern the symbols in your sources.
11:35:26
pjb
For user input, you can (delete-package "MY-RUNTIME-PACKAGE") (make-package "MY-RUNTIME-PACKAGE" :use '()) at the start of the program to clean things up.
11:36:47
pjb
It may be a good idea to have different packages for the program and for user's symbols.
11:40:48
pjb
you could use a temporary package named AOC2019.DAY6.PLANETS-XXX to read the planet names.
11:42:33
boeg
if I just wanted to have intern use the current aoc2019.day6 package, i should just give the second argument "AOC2019.day6" ?
11:42:39
pjb
alternatively, since you need to intern the planet names only for EQ hash-tables, etc, you could just use make-symbol instead of intern.
11:43:38
pjb
planet names are not program identifiers. They don't belong to the package where you intern your program symbols.
11:44:12
pjb
Well, if you use make-symbol you will have to unify them yourself, so better use a temporary package for the planet names.
11:45:17
boeg
just four different strings, so it wasn't gonna bloat the "symbol registry" but yeah, probably a bad decision
11:45:20
pjb
You will have to intern them in a equal or equalp hash-table to find them again (there are several occurences of a single planet name).
11:47:39
pjb
create a hash-table, setf gethash the strings, delete the hash-table, vs create a package, intern the string, deletel the package…
11:48:01
pjb
The only thing is that you want to generate a unique package name in case your program is run in parallel in different threads.
11:48:31
kmeow
what's the right way to export a struct from a package? I'm missing the slot symbols for its constructor
11:49:23
pjb
(let ((*planet-package* (make-package (make-unique-package-name "AOC2019.DAY06.PLANETS-") :use '()))) (unwind-protect (do-something) (delete-package *planet-package*)))
11:50:56
pjb
see for example: https://github.com/informatimago/lisp/blob/c98c1b33fe781bb69d638cfbad4bfa6a241f33f6/common-lisp/interactive/interactive.lisp#L308
11:51:40
pjb
Of course, to ensure thread safety a lock would be needed while generating the unique name.
11:52:09
pjb
in the case of mkupack, it's an interactive function, so we assume the user doesn't call it from threads.
11:53:19
boeg
I could simplify the code now that I understand objects better, get it with `elt` and use case to match on it
11:56:02
pjb
use-package is for compilation-time (or the REPL). not for run-time. For run-time, you would just bind *package* (let ((*package* my-runtime-package)) (read))
12:08:59
_death
kmeow: you cannot export a struct from a package.. all you can do is export symbols, so export make-struct, struct-foo, struct-bar, etc.
12:14:13
kmeow
for something like (defstruct astruct a b c) I've been using (make-astruct :a val1 :b val2 :c val3)
12:14:33
_death
those are usually keyword symbols (i.e. symbols in the keyword package).. symbols in the keyword package are automatically exported, so they can use them from anywhere (i.e. they are global)
12:19:03
_death
if your struct has a state slot, the default constructor function will take a :state keyword argument
14:19:38
galdor
is https://github.com/3b/package-local-nicknames/blob/master/docs.org the last version available for the local nickname spec? it has not been touched for 9 years and error types are marked as TODO
14:21:06
jackdaniel
galdor: see sbcl documentation if you want something what sustained the test of implementing it
14:23:56
galdor
if implementations do their thing and the spec isn't maintained, then yes the spec is dead
14:24:31
galdor
I'm just trying to get a feel of the state of CL in 2019 to see if it makes sense for me to continue investing time and energy in it for my projects
14:25:54
jackdaniel
|3b|: could you copy relevant parts of sbcl documentation to your repo to make galdor satisfied (alternatively less sorrowful)?
14:27:29
jackdaniel
I might have been a little ironic here; needless to say I don't agree with your judgement of "CL state"
14:28:58
galdor
from what I understand, ownership of the CL standard is complicated, which pretty much guarantees that there will never be a new version
14:29:46
galdor
this is disappointing, but could be worked around if there was a way to build some kind of consensus around update documents which will be adopted by major implementations
14:30:15
jackdaniel
local package nicknames are adopted by major implementations and they all follow what is documented in sbcl manual
14:31:06
galdor
it would be nice if local nicknames where based on documents and not on an implementation
14:32:01
galdor
but to be honest, when I see threads such as https://github.com/edicl/cl-ppcre/pull/30 I have trouble finding any kind of motivation
14:37:57
galdor
I'd volunteer for a patch to ASDF to remove the warning (I really don't like how complex ASDF has become, but afaik there aren't credible alternatives, a bit like CFFI)
14:41:33
_death
it's more problematic than that.. if a patch is to be made, then it should be made in the asdf repository and vendors should then take it from there.. but asdf is not something vendors care to update, for good reasons
14:43:03
scymtym
galdor: asdf is still maintained. primarily by rpg but with help from fare as far as i know
14:43:39
_death
it reminds me of https://adeht.org/usenet-gems/sysdef-spec.txt .. there should be a spec and vendors should be free to implement it themselves or use some existing implementation
14:46:16
galdor
it feels to me lots of people agree this warning is annoying and useless, but it seems no one has the authority to fix it
14:49:29
galdor
i'd say both issues are linked to the lack of people in the CL community, there aren't just enough of us
14:51:55
Bike
i guess i could submit the SBCL manual section about package local nicknames as a CDR or whatever
14:54:23
Shinmera
because people just saying "you should do this" is not enough incentive for implementations to actually put in the work.
14:54:40
Shinmera
the only reason the standard ever happened was because the implementors wanted to collaborate.
15:11:43
Shinmera
phoe said he might consider tackling sequences once my trivial package has a test suite
15:15:29
Shinmera
Thinking around that kinda stuff, I wonder how many implementations offer hash tables with custom tests.
15:16:51
Bike
sbcl supports an extension for this, no idea if it matches the CDR, dunno about other implementations
15:18:45
Bike
hash tables might be kind of weird portability-library-wise, since there's this extension and there's the weakness extension
15:19:13
Shinmera
weakness is handled by trivial garbage, but yeah, combining the two would produce overlap.
15:20:05
Bike
yeah that's what i mean. trivial garbage has make-weak-hash-table, which probably doesn't support custom hashing
15:37:43
MichaelRaskin
hu.dwim.walker rots, and it's because package names and layout change (apparently without any change that would be visible in the — definitely nice and useful — table you keep)
15:39:15
Shinmera
If you notice a discrepancy, by all means send a patch or let me know what needs changing.
15:39:48
Shinmera
The site was designed to be very easy to update. https://github.com/Shinmera/portability/blob/master/data.lisp
15:40:58
MichaelRaskin
I _think_ that the changes breaking the walker did not take anything away, so I don't have any changes in terms of the table. Anyway, I gave up and wrote Agnostic-Lizard.
15:42:05
MichaelRaskin
But my point is that code existing is not the only thing to go, coordination is more for catching up with JavaScript in terms of feature probing, not for pressuring people into writing and debugging code they don't care about
16:31:55
oni-on-ion
for haskell standard, let's say Haskell '98 or Prime, most use GHC as the crazy-advanced hyper-optimizing supercompiler. this is a bit of a lock-in to implementation, aside from some outliers whom still are based on GHC
16:32:25
oni-on-ion
now for CL, what is the usefulness of adhering to standard, if most cases are using SBCL ?
16:33:37
beach
If you are using only SBCL and you don't care about other implementations, and you believe SBCL will be around for some time, then you do what you wnat.
16:35:01
oni-on-ion
pjb, because i am thinking, emacs lisp is surely the most "portable" kind of lisp. i dont think anyone is choosing CL specifically to be portable. long-lasting (stability) strength of CL is not considered however
16:35:13
pjb
oni-on-ion: If you write conforming CL code, you get de-jure portability: you can run on all conforming CL implementations!
16:35:23
_death
oni-on-ion: most, but not all.. and even if SBCL was the only implementation around, the standard keeps interfaces stable
16:50:45
Shinmera
oni-on-ion: I spend most of my time writing libraries. I want those to be useful for as many people as possible, so in order to account for as many use-cases as possible, I care about them being portable.
16:51:20
Shinmera
beach: SBCL runs on android, just not in a convenient way to be useful for writing Android apps.
16:55:57
oni-on-ion
Shinmera, ah yeah =) my short-sighted worry is nothing changes under me, so i can work on code base until i die. like say haskell or ocaml or web code wont work after a few months
16:56:14
beach
#lisp seems to be the channel of extremes. One minute we have an opinion insisting on an update to the standard for package-local nicknames. The next minute we have an opinion questioning the usefulness of the standard.
16:57:13
oni-on-ion
to be clear, to me the CL standard is the most useful of all standards, in programming
16:58:02
oni-on-ion
but i was curious how much the portability factor across implementations is relied upon -- Shinmera makes a good point. i wasn't thinking about apis/libraries, just as personal/proprietary code base substrate
17:04:51
MichaelRaskin
With personal code, you sometimes can use the differences in what different implementations complain about to clean up some of the corner cases
17:06:06
oni-on-ion
true; ive seen some doing this. but i've also seen some giving up on other impl's and sticking with one after giving up supporting the rest (im looking at you aeth =)
17:54:08
vivit
When I attempt to quickload CLSQL-SQLITE3, I get the following error: 'Component CLSQL-UFFI-SYSTEM::UFFI does not match version 2.0, required by #<SYSTEM "clsql-uffi">'
17:55:04
vivit
The only information I can find online about this specific error seems to be one where the user apparently was having problems because he was using CLisp despite CLSQL not fully supporting CLisp, but I'm using SBCL
18:17:39
kmeow
(ql:quickload "sqlite") completes without error, though idk if those are at all related
18:36:15
reepca
The :from-end keyword arguments in the sequence functions... I thought I had a good intuitive understanding of what they did ("start searching from the end"), but now I'm reading the hyperspec entry of POSITION and apparently my understanding was backwards?
18:36:44
reepca
"The position returned is the index within sequence of the leftmost (if from-end is true) or of the rightmost (if from-end is false) element that satisfies the test"
18:38:09
reepca
but the first example contradicts that, because the element at index 4 is not the leftmost element that satisfies the test...
18:45:43
edgar-rft
reepca: it's a known error, see https://www.cliki.net/ANSI%20Clarifications%20and%20Errata
18:47:44
kmeow
I'm trying to compile a script in SBCL, and I get +100 errors but it still spits out a fasl at the end
18:51:46
kmeow
thought I had an actual question, but looking over the errors again I'm so baffled I'm not even sure where to begin
18:55:52
kmeow
yeah, I'm browsing ANSI Common Lisp looking for a description of the compilation process
19:07:08
reepca
sometimes I think sbcl is too clever for its own good. It can figure out that the last iteration of a loop will always cause a type error and therefore delete the code after the loop as unreachable, but can't tell me why it deleted it and save me the time of analyzing it myself
19:08:37
reepca
put the declaration at the top of the function in question, it still just says "deleting unreachable code" and nothing else
19:12:21
jackdaniel
it is easier to do something than explain clearly why it has been done (in compilers), so I suppose nobody bothered to implement explanation function
19:13:10
reepca
it would actually be pretty interesting to try to implement a compiler that focuses on being able to answer "why" questions.
19:36:23
aeth
reepca: Well, wouldn't the "why" just generally be proving, while showing sufficient steps, that some optimized form is equivalent to the original? So it sounds possible.
19:36:59
aeth
For the unreachable code example, it would show you why the eliminated branch(es) can't be reached.
20:00:08
jackdaniel
n.b same goes for the systems which make automated decisions (be it machine learning or expert systems) -- a very appealing features is to make these things to answer why they made some choice (i.e provide a rationale which makes sense to human being)
20:37:04
jackdaniel
I've applied a loose meaning of "hard"; it is different hard for comiplers and different hard for ML. The former is that making good meaningful compiler messages with source location (and visualisation) requires a lot of thought, providing rationale for decisions is a few steps harder