freenode/#lisp - IRC Chatlog
Search
14:02:08
Xach
jmercouris: It would be nice to have something that did "make the package definition be exactly this"
14:05:08
jmercouris
swank does some stuff to the lisp image when it gets the idea of re-evaluating a form containing a defpackage
16:48:11
flip214
If I need a function on the host and in javascript, how can I tell Parenscript to provide both?
16:48:26
flip214
a (PS (DEFUN ...)) results in a string that's to be sent to the client only, right?
16:50:55
flip214
Bike: well, things like (AREF) and (1+) etc. are the same, for many practical purposes.
16:51:43
Bike
or do some nonsense with #. or macros to avoid actually having it twice in the text, yeah
16:52:12
Bike
i mean, if you have (defun foo (x) x), that's fine in both parenscript and the host, but they go through different compilers, no?
16:52:20
flip214
well, of course I can read the source file at compile time to get the javascript string, and let it be read via ASDF as usual
16:52:43
flip214
Bike: I've got some functions (and a few constants etc.), and I need to have them both in the server and the client.
16:53:14
Bike
just have the code twice, i think. there's like, hardly any relation to having code in parenscript and having it in the host.
18:42:59
fiddlerwoaroof
I believe there's a surprising amount of overlap between parenscript/lisp that makes it somewhat feasible to share code between the languages
18:44:18
fiddlerwoaroof
flip214: one thing you could do is put all the common functions into their own files, include them with asdf and then serve them with a handler that loads them at runtime (or compile-time via macros)
18:45:54
fiddlerwoaroof
something like: (ps:ps (asdf:find-component (asdf:find-system :fwoar-lisputils) "hash-functions"))
18:46:19
fiddlerwoaroof
you'd have to make sure that you have defined a JS "runtime" that conforms to your expectations, though
19:33:27
borodust
hi Xach, any news about PGP support for quicklisp dists? are there a rough ETA around?
20:16:57
buffergn0me
flip214: it me, new nick, but it's true I have only started hanging out on IRC again recently
20:18:43
buffergn0me
You can have a macro that takes a defun (or a body of code) and returns it as-is for CL, and generates the appropriate code to say "also compile these forms with PS and put the result wherever JS is supposed to go"
20:20:53
buffergn0me
Or you can have a separate file(s) for shared code, that just goes in the ASDF definition, and then also gets compiled with PS with whatever tooling you have set up to compile/concatenate/serve etc JS
20:32:36
Grue`
sharing code between Lisp and Javascript? Sounds like the job for cl-clojure-template ;)
20:38:14
Grue`
ecraven: https://stackoverflow.com/questions/44698426/how-do-setf-works-under-the-hood
20:39:51
Grue`
interestingly setq also uses setf expansions, because a symbol-macro can expand into a generalized reference
20:40:35
ecraven
hm.. so defsetf "just" associates the setter with a getter, and the macro expansion of setf then uses that setter?
20:45:34
flip214
buffergn0me: do you have an example? didn't see that kind of code sharing in the docs.
20:46:43
Bike
ecraven: defsetf and define-setf-expander and so on fundamentally just define how setf forms macroexpand
20:47:23
flip214
in ITERATE, can I have some more variables stepped with a generator automatically? something like this:
20:48:00
flip214
(ITERATE (generate element in list and el-car = (car element) and el-cdr = (cdr element)) ... (next element))?
20:48:58
Grue`
ecraven: there can be "setf expanders" defined for various functions, and also there exist functions named "(setf foobar)" that are also used by setf
20:51:12
Grue`
ecraven: http://clhs.lisp.se/Body/05_ab.htm this should be a complete list of how setf decides what to do with its first argument
20:51:57
buffergn0me
flip214: (defmacro shared-code (&body body) `(progn ,@body (setf *ps-forms* (append ',body *ps-forms*))))
20:53:04
buffergn0me
flip214: Then you can (ps* *ps-forms*) in whatever HTTP request handler you have
20:53:26
Inline
the documentation example call is like (%foreign-funcall "sqrtf" :float 16.0 :float)
20:55:37
buffergn0me
flip214: Or write them to a file. Or put them into an in-memory cache and serve them up under a unique URI with long-lived HTTP cache headers
20:57:12
pjb
(multiple-value-bind (q r) (truncate 10 3) (values q r)) == (let (q r) (setf (values q r) (truncate 10 3)) (values q r))
20:58:32
pjb
(defmacro multiple-value-bind ((&rest vars) expression &body body) `(let (,@vars) (setf (values ,vars) ,expression) ,@body))
21:01:31
flip214
buffergn0me: no, sorry. the basic logic is sound. I just hoped that parenscript already includes something like that shared-code macro.
21:04:12
Grue`
the whole point of multiple values is to avoid consing so multiple-value-list should be used only as last resort
21:04:18
flip214
buffergn0me: I guess I'll generate the string for JS by reading some source file during compile-time -- that way I can avoid the extra outer macro.
21:04:25
buffergn0me
flip214: I could not figure out a way to support all the possible use cases: multiple forms in multiple files of mixed, inlined, or separate code have to go to multiple arbitrary output places (dynamic handlers, cached static handlers, files, things that have nothing to do with a web server)
21:05:22
flip214
I would have hoped for a (parenscript:next-defuns-into *some-js-functions) (parenscript:defun ...)
21:11:37
PuercoPop
One thing about the streams API in CL I never quite understand is how I create a custom one. Say I'm trying to open a binary-stream that I can read from in FIFO order what I write into. Or even just write to an array. What I'm currently doing is writing and read from a file but that isn't quite what I want. Is writing my own graystream the way to go?
21:12:26
pjb
PuercoPop: you cannot within the ANSI CL standard (unless you re-implement this CL API in an extensible way, cf. com.informatimago.vfs).
21:12:48
pjb
PuercoPop: on the other hand, you can use the de-facto standard of Gray Streams, which is implemented by most implementations.
21:12:48
buffergn0me
flip214: I have not heard of COMPILER-LET before. CLtL2 already lists it as removed
21:12:50
buffergn0me
flip214: You can do something like that by modifying the value of *parenscript-stream* in an eval-when in PS code
21:14:43
no-defun-allowed
when Gray Streams are usable, they are much more likely to "just work" with other CL code
21:18:04
flip214
buffergn0me: I still need to provide my own LISP+JS-DEFUN macro -- but that's okay. I'll play around a bit.
21:18:45
_death
Gray streams are not the only way.. https://gist.github.com/death/5356be28dc3332caa189c91880fe12c6
21:21:57
pjb
_death: I'd agree. Just note that the gray stream itself could be defined more correctly.
21:22:29
pjb
PuercoPop: sure. But be careful, when using pipes, you need multiple-threads, because I/O are blocking.
21:23:55
_death
also, on sbcl they require this fix: https://github.com/death/sbcl/commit/399170635d5dad01b2866437fa35b14a7de01a1d
21:25:09
fiddlerwoaroof
_death: hmm, my inclination would be to have the decompressing stream always return octets and then wrap that with a flexi-stream
21:26:35
fiddlerwoaroof
And, when it is, you're probably going to want to avoid generic functions altogether.
21:27:55
_death
anyway, the issue is deeper than that use-case.. it should really be a lesson about design of protocols
21:28:12
PuercoPop
pjb: I'm not worried about writing portable code, the xcb library I'm wriiting is SBCL only
21:29:21
jmercouris
eg. (loop for item in items do (some-operation)), when some-operation returns a non-value
21:30:34
_death
so I feel that Gray streams is not part of CL is a good thing, and that also touches on arguments for further standardization...
21:31:00
pjb
Oops, yes, thereis works: (loop thereis (let ((x (random 10))) (if (evenp x) nil x))) #| --> 1 |#
21:31:09
specbot
Termination Test Clauses: http://www.lispworks.com/reference/HyperSpec/Body/06_ad.htm
21:31:25
pjb
I tried it on a boolean, so I thought it only returned nil or t, but it returns the value.
21:33:55
jmercouris
if there is no value, there is no value, I am no magician, I can't fix everything wrong with this database
21:34:45
flip214
jmercouris: why not (OR value (format nil "~36r" (RANDOM (expt 36 10))) to get around that?
21:37:15
jmercouris
and my goodness woocommerce, stores orders as, let me blow your mind, wordpress posts
21:37:34
jmercouris
how do you know the information about the order? obviously that would be in the wordpress post meta table
21:39:02
fiddlerwoaroof
well, the problem with a lot of these things is that the underlying platform isn't an ecommerce platform
21:39:29
fiddlerwoaroof
so the extensions just shoehorn their stuff into the existing data structures.
21:39:57
jmercouris
They have more than enough money to do a clean rewrite and migration for woocommerce..
21:40:50
fiddlerwoaroof
Woocommerce doesn't provide some sort of XML "export all information" functionality?
21:42:12
jmercouris
I'm too deep into this though, and I need stripe data to perform a smooth transition anyway
22:01:52
dxtr
I thought about it multiple times but I figured it simply wasn't worth it. So much stuff that has to be done and has to be done right (e.g. the ability to customize the tax rules in every way imaginable for every jurisdiction and situation)
22:02:24
fiddlerwoaroof
dxtr: yeah, I also worked with Sylius (avoiding Magento) and that was a different sort of nightmare
22:02:29
jmercouris
I am not looking to usurp these platforms, I was thinking about writing a *very simple* ecommerce system
22:03:15
fiddlerwoaroof
I thought about that too, but there are a number of hard-ish boring problems any ecommerce system has to solve
0:06:28
fiddlerwoaroof
comborico1611: I'm not sure I understand the question, it's just a normal function
0:10:00
comborico1611
I figured it didn't need to be defined. I imagined that somehow the stucture would get tagged onto the OP part of op-add-list
0:12:44
fiddlerwoaroof
something like (defstruct op add-list) should give you the function you want implicitly
0:14:06
comborico1611
Hmm. I'm not sure how that works, but I figured that was what was going on. (It's not my code.)
0:14:36
fiddlerwoaroof
the way a defstruct works is that the struct name gets combined with the slot name, separated by a hyphen
0:16:05
comborico1611
How does Lisp know that the OP in op-add-list is to be swapped with OP in lambda list?
0:18:20
comborico1611
I can't think of another way to rephrase it. But at least now I know that the code is correct, that it should be an implicit thing.
0:19:11
fiddlerwoaroof
It would probably be helpful to provide more context, it's hard for me to tell what the problem is and how those two bits of code are related
0:20:05
fiddlerwoaroof
However, without some additional definition like (defun op-add-list (thing) (action-container-add-list thing)), the two snippets of code won't work together.
0:22:50
comborico1611
I see! Yes, that is what I thought. But this code comes from a book. https://pastebin.com/eLkMf1an
0:43:04
edgar-rft
comborico1611: 1) there are a megaton of typos in that file, looks like machine-scanned code with no human error correction 2) the function FIND-ALL is nowhere defined in that file
0:48:19
edgar-rft
comborico1611: It looks like code from Norvig's "Paradigms of Artificial Intelligence Programming". But I can't even compile the code without the missing definition of FIND-ALL.
0:56:57
edgar-rft
comborico1611: this version works for me <https://pastebin.com/iWfbYf7a>, the only real problem were the huge number of typos
0:57:50
comborico1611
Haha! Hey! Thanks for letting me know it works. I now have encouragement to continue trying to figure out teh problem. Thanks.
1:01:09
edgar-rft
comborico1611: PAIP is not an "easy" book but you can really learn a lot out of it :-)
1:02:44
edgar-rft
looks like a special version of IF that was written by somebody else (not contained in the standard)
1:11:03
pjb
It's easy, it presents a nice and rather complete tutorial of CL, it presents famous algorithms in a very clear and modern way.
1:14:44
edgar-rft
pjb wanted to say that PAIP is also an introduction to CL, but for much more advanced programmers, so it always depends on what you expect :-)