freenode/#lisp - IRC Chatlog
Search
12:00:57
no-defun-allowed
That's definitely good practice, since then users can subclass those classes and create them dynamically.
12:01:34
pjb
fivo: you cannot export classes in lisp from anything (in the CL standard; you can always invent your own concepts).
12:03:07
fivo
ok, so it's no possible to just export the symbol of a class and have access to all the readers/writers
12:03:34
pjb
fivo: what this tutorial means to convey, is that you should define and document your own API. It is valid to define make-instance '<your-class> as the API to instanciate objects of your class, and to specify that they're CLOS object.
12:04:26
pjb
fivo: but if you could want to implement them as structures or as something else (eg. a reference in a database, a handle), then you may want not to publicise the fact that they're clos objects and it's a class.
12:05:02
pjb
fivo: in that case, you would define your API in terms of functions such as make-person, instead of a clos class with a constructor such as make-instance 'person.
12:05:54
pjb
fivo: and yes, you get to choose the precise list of accessors you want to export. Some accessors may be "private".
12:07:19
pjb
Since CL is a lisp-n, (cf. lisp-2 vs. lisp-1) a symbol can name several things. When you export it, thru it you give access to all the things it names.
12:11:17
fivo
ok so there is no mechanism to automatically export all accessors whenever I export the symbol of clos class? (maybe also for a good reason)
12:32:52
selwyn
fivo: you may be interested in cl-annot https://github.com/m2ym/cl-annot#annotation-export-accessors which provides this functionality with read macros
12:33:44
beach
pjb: There is no such thing in the Common Lisp HyperSpec as a "CLOS object". The only reasonable meaning of such a term would be equivalent to "object" or "datum".
12:34:31
beach
fivo: Yes, very good reasons. You almost never want to do that, so the functionality is fairly limited.
12:35:30
_death
you may also be interested in this: (defun thoughtful-export (symbols &optional (package *package*)) (dolist (symbol symbols) (when (y-or-n-p "Do you really want to export the symbol ~S?" symbol) (export symbol package))))
12:36:23
_death
you should think about the external interface first, instead of automatically exporting symbols
12:37:47
p_l
fivo: also, package nicknames, and available in some systems package-local-nicknames, allow you nice shortnames that help with things
12:38:15
katco
can anyone recommend a common-lisp equivalent to pandas? the only one i can find that appears similar is cl-ana http://pandas.pydata.org/
12:39:10
p_l
Josh_2: it's good to think on external interface, including which symbols need to be qualified
12:39:22
beach
There is no problem exporting names of classes, especially if you want client code to be able to subclass, define :AROUND methods, etc.
12:40:15
beach
Josh_2: As several people pointed out, it is not whether it's a class or not that counts, but whether the entity is part of the external protocol.
12:41:52
beach
Josh_2: The stuff you want to present to client code. Called API or Interface in other contexts.
12:43:58
beach
Josh_2: There is no problem. If your symbol names something that is part of the protocol, then export it, otherwise not.
12:48:50
Nilby
_death: lol, I think I need to make the whole thoughtfull-* suite, especially thoughtfull-defsystem, and thoughtfull-setf
12:55:57
_death
you can also add (unless (documentedp symbol) (setf (docstring symbol) (prompt "Please enter documentation for ~S:" symbol)))
13:18:05
pjb
beach: object and datum include objects of build-in classes. What I mean by CLOS objects are instances of standard-object; there remains instances of user-defined standard-classes.
13:23:36
pjb
katco: why would anybody want an equivalent of pandas? They're stupid, lazy, evil, gluttonous, (and they eat something they're not supposed to eat), they don't reproduce, and they cost a lot of CO₂, being shuffled around in planes.
13:24:28
pjb
_death: (unless (documentation symbol t) (setf (documentation symbol t) (prompt "Please enter documentation for ~S:" symbol)))
13:25:44
beach
pjb: I know what you mean, but it is better to use the established terminology, i.e. standard object.
13:49:18
beach
iarebatman: It is a much better strategy to describe what you need. Then people who do not know the language you are referring to can also help out.
13:51:45
iarebatman
beach: Thanks for the tip. Is there a convenient way to traverse an alist/plist depth-wise to get at a value at a certain 'path' ? ex, instead of nesting several (cdr (assoc))s, something like (get-in alist '(:first :second :value-of-second))
13:56:29
Xach
iarebatman: in my experience it is not so common to construct objects that require key path lookup like that in CL, and I don't know of a popular library to do it. (it seems pretty common when processing e.g. json though)
14:02:53
Josh_2
Is there a guide somewhere that explains in laymans terms how the heck to deploy an app in CL and why certain steps have to be taken. I've deployed before but never anything more than like 100lines of cl
14:04:30
Josh_2
Well I have an app that I have made and I tried to dump the image but it isn't functioning properly
14:05:20
Josh_2
It's not functioning properly when dumped. pjb has gone over some things with me but I was hoping there would be a nice guide that explains why things are the way they are
14:05:30
iarebatman
Josh_2: I'm definitely no expert in CL, but I was able to easily build a native executable with buildapp
14:09:25
Xach
Josh_2: the commercial implementations have guides to deployment/delivery but they don't directly apply to other implementations
14:12:30
fivo
iarebatman: If you want to parse json, you might want to look at https://github.com/hanshuebner/yason
14:13:06
Josh_2
with buildapp I specify the location of the --asdf-path and then name the package I created with --load-system ?
14:13:38
Xach
Josh_2: --load-system is for loading systems - systems usually load files that define packages.
14:17:42
Xach
i have one rule that builds the project with Quicklisp, that means all the prerequisites are available. the next rule dumps a quicklisp system manifest file. the next rule uses that manifest to build my program binary.
14:19:51
iarebatman
fivo: the parsing is fine with cl-json, it’s after it’s been turned into cl representation that I was looking for a better way to extract nested values
14:22:55
mfiano
Keep in mind that you have to explicitly unload any foreign code that is loaded in the image prior to dumping it, and then re-open the libraries in a function called on initialization. You can't dump the path CFFI used to load the library on *your* system.
14:26:46
Josh_2
Basically when I load normally with asdf in sly I have no problems, if I use a function to load the asdf then dump the image the server doesn't work properly, tcp seems to work but udp doesn't
14:27:35
Josh_2
because when I move my fingers on my android screen, normally repl spews tons of output :P
14:29:14
Xach
Josh_2: i don't think there is a general guide, just practice and troubleshooting, sorry.
14:29:23
Josh_2
Xach when I finish eating I will demonstrate how I create the image etc and what happens
14:48:16
Josh_2
Actually the networking seems to be working I'm not sure, my phone clearly connects but the move-mouse function isn't moving my mouse
14:53:00
Josh_2
Well I fixed why move-mouse isn't working in the image, It's set using (defparameter ..) and pjb was talking yesterday about how globals need to be setup in a different way
14:57:29
Josh_2
So I'm guessing I need to create a function that sets up all my global variables and call that as my top level function?
15:00:57
dlowe
when you reload the file, if the variable is already declared, it won't overwrite the value
15:08:30
katco
i'm packaging gsll for a linx distro called guix, and i'm running into an issue i don't understand. guix compiles packages using `asdf:compile-bundle-op`. gsll compiles just fine, but when i go to load it in sbcl, i get an `cffi::undefined-foreign-type-error`: "Unknown CFFI type :SIZET". any ideas?
15:11:15
katco
Xach: some searching suggests you ran into something similar in 2016 with quicklisp and cl-glu, but it looks like that was a compile-time
15:46:03
Josh_2
I have :export in defpackage and am export two symbols "wait-to-play" and "setup-x-control" but this always says these functions are not external to to my package Q_Q https://plaster.tymoon.eu/view/1355#1355
15:48:32
sjl_
But by default, the lisp reader will uppercase symbols when it reads them. So the symbols you're trying to access in lines 22/23 are named "SETUP-X-CONTROL" and "WAIT-TO-PLAY"
15:50:16
sjl_
You're already using uninterned symbols for the package name and in the :use, you could just do the same for the :export list.
15:58:00
vms14
I have troubles while designing, and I guess with bottom up design will be easier than what I'm used to do
15:59:29
sjl_
it takes a little while to get used to, but once you do it's pretty nice to work with. there are just a couple of annoying edge cases that newbies often hit.
15:59:33
vms14
The program I don't know how to design is some kind of forum with hunchentoot, to learn lisp and backend at same time
16:01:21
vms14
bottom up design suggests start to creating functions like "create-post" "create-user" and go abstracting step by step?
16:02:12
Josh_2
https://plaster.tymoon.eu/view/1356#1356 I have that file which is called save-image.lisp I load it in sbcl from term run (save) it produces the executable I use ./server it then returns instantly
16:03:52
Josh_2
vms14: http://dept-info.labri.fr/~strandh/Teaching/PFS/Common/Strandh-Tutorial/bottom-up-programming.html
16:06:05
Josh_2
just like if u learned CPP as first language OO is probs how you think about a problem naturally
16:08:09
sjl_
Josh_2: I'm not sure exactly what you're trying to do, but often people distribute binaries in CL by doing something like:
16:08:11
sjl_
1. Run Lisp on your machine. 2. Load all your code into that Lisp process with ASDF, Quicklisp, whatever.
16:08:13
sjl_
3. Use save-lisp-and-die with :toplevel 'mypackage:foo to produce a binary that will call the function mypackage:foo when it's run.
16:08:15
sjl_
mypackage:foo would initialize any variables/whatever that depend on the computer it's being run on, and then it would do the actual useful thing you want the program to do.
16:08:49
vms14
as for a program that creates a forum, I should start by functions like "create-post" and go creating functions from that
16:09:37
vms14
and don't think about implementation until I'm on the step that needs to be implemented
16:09:46
sjl_
In your snippet, I don't know why you're calling (load-up) twice, the in-package isn't necessary and/or helpful, and I don't know why you're calling sb-impl
16:22:10
Bike
i mixed up something obvious and string< doesn't work like i thought, so, is there an easy way to sort a list of strings in lexicographic order?
16:25:29
Bike
well, what i'm actually trying to do is sort a list of (symbol ...) by the symbols, by sorting the package first and then the symbol names
16:25:56
Bike
so i'm sorting with (or (string< (package-name (symbol-package s1)) (package-name (symbol-package s2))) (string< (symbol-name s1) (symbol-name s2)))
16:26:06
Josh_2
sjl_: okay that worked, but now my executable just shuts instantly, is there a function I can call to take my to the sbcl top-level?
16:26:31
sjl_
Bike: you need to have another check for string< p2 p1 before you move on to compare the symbol names
16:27:09
Josh_2
the function I call 'x-control:setup-x-control sets up the params and then calls the main function, however that function works in the background on seperate threads
16:28:23
sjl_
at some point I wrote a compose-predicates-for-sorting function but I can't remember where I put it
16:30:51
dlowe
(also, they couldn't be simple predicates without some annoying duplication of effort
16:32:37
sjl_
Josh_2: Ah. Do you actually WANT the REPL, or do you just want the thing to not immediately exit?
16:35:21
sjl_
Then sb-impl::toplevel-init might work. Unfortunate that it's not exported/part of the public API
16:36:35
sjl_
You can use it, you just don't get any promises from the SBCL folks that they won't rename it or change it in the future.
16:37:11
sjl_
Not if you don't WANT it to go into the REPL after. In your case you do, but for other programs you might not.
16:39:22
sjl_
I suppose you could make everyone that DOESN'T want the REPL call (sb-ext:exit :code 0) manually, rather than making the people who DO want the REPL call the REPL function.
16:43:04
Josh_2
I'd have a functional phone computer mouse if I could get clx to click and unclick :(
16:55:51
Josh_2
Heres another question. CLX comes with a folder called "extensions" but the functions contained within aren't callable with (xlib:fake-motion-event ..) for example
16:56:30
sjl_
Bike: dlowe: from memory I think it was something like this https://plaster.tymoon.eu/view/1357#1357