freenode/lisp - IRC Chatlog
Search
12:38:39
fiddlerwoaroof
elderK: I've always found images like this useful, https://upload.wikimedia.org/wikipedia/commons/4/43/Method-combination.png
12:46:40
jmercouris
Hi everyone, trying to solve some issues with macros: https://gist.github.com/jmercouris/8ad669f06ffc6fd0580d3f2a5aa60b71
12:47:51
jmercouris
the only thing that I've come up with is that I have to change the signature of BUFFER-EXECUTE-JAVASCRIPT
12:49:57
jmercouris
I'm not sure if it is clear what I'm trying to do here: but I want to be able to create functions that invoke some parenscript on a given buffer, but also use those same functions within with-result (since parenscript/js invokation is asynchronous) if I want the value asynchronously returned by the JS function
12:51:39
jmercouris
in the example I've given in the gist, I would like to be able to say (scroll-to-top) as well as (with-result (result-value (scroll-to-top)) (print result-value))
13:01:11
mercourisj
I don't want to make a different macro, like (with-parenscript ...), I want it to be consistent throughout the codebase
13:01:11
jackdaniel
reducing this example to something minimal illustrating a problem would be a good idea (with a clear statement, what do you expect - any "desireable" expansion or you just ask someone to fix your code)?
13:02:48
mercourisj
if you were to design a continuation passing style macro, what would it look like?
13:03:15
mercourisj
e.g. (with-result ((result-value (function-with-callback))) (print result-value))
13:03:57
mercourisj
is it bad that my with-result depends on the first argument to the function-with-callback function be a callback?
13:04:36
mercourisj
jackdaniel: if you look at my gist, you'll see what with-result, is my attempt at making a macro that makes continuation passing style simpler
13:04:58
pjb
mercourisj: (defun swap-args (fun) (lambda (&rest args) (apply fun (first (last args)) (butlast args))))
13:07:02
schweers
I’m currently using defmethod, saving the result and immediately removing the newly added method again, in order to be able to add and remove it later.
13:09:18
elderK
Guys, is it safe to use with-accessors if you have a reader, but not an "accessor"? Like, no reader/writer combo, provided you never setf to a var representing a slot?
13:12:58
trittweiler
mercourisj, Are you sure this is a good way to go? In my opinion it is quite horrible. Invocations within with-result look different than their lambda list definitions. Have you considered using promises rather than cps? So read-from-minibuffer would return a promise.
13:19:12
pjb
elderK: if you have reticences, you can always use (symbol-macrolet (foo (foo x)) … foo …)
13:20:14
pjb
or define a with-readers macro. Notice that with-accessors expands to such symbol-macrolet, and your with-readers would expand exactly the same.
13:20:35
pjb
But having a with-readers macro would make it clear that you want just to read the slots.
13:21:17
pjb
ie. it's part of functional abstractions. You can define functions or macros just to give nice names to the operators, they don't need to do anything more.
13:22:09
Bicyclidine
schweers: you can make-instance 'standard-method. the mop documents online explakin the parameters somewhere.
13:23:03
Bicyclidine
http://metamodular.com/CLOS-MOP/initialization-of-generic-function-and-method-metaobjects.html here.
13:24:37
shka_
https://github.com/sirherrbatka/vector-classes/blob/c8db51eb68d3d503ec7a6691f2ef710b06d5ef36/src/protocol.lisp#L88
13:25:12
Bicyclidine
unless you want to ask about make-method-lambda, in which case i apologize in advance
13:35:02
makomo
fiddlerwoaroof: that's a nice picture visualizing the standard method combination, thanks :-)
14:21:41
elderK
You know, the X3J13 issues are actually a kind of interesting read in and of themselves.
15:26:42
francogrex
Hi, do you know if there is a way to mprotect a memory address to make it exec from lisp?
15:29:21
Xach
elderK: also the gang of five email list, which was assumed private and has some gossipy snark
15:30:17
francogrex
cffi:foreign-funcall-pointer a pointer to execute an asm code, in my 32bit the address is executable, in 64 bit it isn't
15:32:31
elderK
francogrex: Yeah, if you've created some... "machine code", you're going to need to tell the system to treat that data as executable, the pages that it lives on
15:33:25
elderK
So, I guess you'll need to use the FFI to acquire memory suitable for that "binary code", as well to make the relevant pages executable.
15:34:33
elderK
Use the FFI to give you access to functions to say, allocate foreign aligned memory.
15:34:35
francogrex
do you have a pointer, a address (no pun intended) of a webpage that explains that?
15:36:38
elderK
Studying the relevant manpages for those functions, and related ones, should do the trick.
15:38:24
francogrex
elderK: yes i actually could use the cffi to do those indeed (in an impl independent way)
15:52:21
pjb
francogrex: the how is easy: write it in C; the translate it to lisp using CFFI for the calls and data structures that cannot be translated.
16:00:14
jcowan
Better yet, write a C->CL compiler (or better, get Vacietis working). "Build a man a fire", etc.
16:12:16
Xach
wusticality: there is a lot of freedom of implementation, as long as the results are consistent
16:12:30
Xach
wusticality: there's a great book that lays out many options, it's called Lisp in Small Pieces.
16:12:35
wusticality
is only the -binding- for x captured in the closure, or is the entire lexical environment somehow
16:13:01
beach
A function can be thought of as an environment and some code. When the function is called, the caller provides the environment to the callee. The callee can then create lexical variables extending the base one.
16:13:11
wusticality
another question is if it's somehow done by the compiler / interpreter, or if it's somehow done with the respective function / macros let / lambda
16:14:10
wusticality
beach: interesting - so is the callee's environment somehow passed as an invisible argument to the callee?
16:14:20
beach
wusticality: The LAMBDA turns into some code that captures the current environment and packages it up to become the closure, i.e, the code/environment pair.
16:15:01
wusticality
beach: is that an artifact of the lambda special form, or via a macro, or what? i'm mostly just curious if it's done in lisp somehow, or if it's an artifact of the compiler
16:15:18
Xach
there's an older book called Anatomy of Lisp that may be available more cheaply, but I did not find time to read it and I don't know if it is useful on this topic.
16:16:29
beach
wusticality: I don't know why you are talking about artifacts. And why you make a difference between "the compiler" and "lisp".
16:17:01
beach
wusticality: The compiler detects that X might be captured, so X is not allocated on the stack or in a register as it otherwise would.
16:17:06
wusticality
I mean, I'm super familiar with closures, but reading Practical Common Lisp, I'm curious how it's actually implemented - that is, at the compiler / interpreter level or in lisp somehow using some macro magic
16:17:56
Xach
wusticality: Lisp in Small Pieces does a nice progression from a slow interpreter to a fast one by showing the tricks that can be brought to bear for efficiency.
16:18:20
beach
wusticality: Instead, it is allocated on the heap in some kind of structure. The compiler generates code for LAMBDA that captures that structure and the code for the function and creates a closure object.
16:19:30
beach
wusticality: When the closure object is called, the compiler has arranged for the caller to grab the environment out of the closure object, stick it in some pre-defined place, and call the code of the function.
16:20:33
wusticality
i definitely want to read more about how it's implemented, i'll check out those boks
16:21:28
beach
jcowan: If you find a bootleg, I would like to know so that I can report it to the translator (who is my wife).
16:23:55
Xach
I thought technical books were expensive until I got a tractor and priced useful attachments for it
16:26:04
pjb
https://www.amazon.fr/Lisp-Small-Pieces-Christian-Queinnec/dp/0521545668/ref=sr_1_1?ie=UTF8&qid=1542212653&sr=8-1&keywords=lisp+in+small+pieces
16:28:22
jcowan
I think more than twice before I buy any book costing more than USD 5 (approx EUR 4.5)
16:30:31
jcowan
My life expectancy does not permit me to think as many times as it would take to justify a purchase of that size. Not to mention the time it takes to learn French.
17:01:31
cage_
minion: memo for Posterdati: probably you are interested in this: https://notabug.org/cage/cazzilli ;-)
17:34:37
Xach
I also have a chainsaw. I try to be very, very careful and use all available safety equipment.
17:56:13
luis
The LIDL supermarkets were selling chainsaws a while ago but I couldn't convince myself (or my SO) that I actually needed one. It was quite tempting, though.
20:02:34
dim
that's from cl+ssl, is there a known quick-fix or approach to this problem? other tools on the same machine don't seem to have any problem...
20:28:49
anamorphic
Seems like the bit twiddling features of Common Lisp are better than those of low level languages
20:29:54
sjl_
that one seems like it almost *has* to be included for historical reasons... otherwise why not just use (logand x (lognot y))?
20:30:37
shka_
sjl_: you are ending up writing such code so often that it makes sense to me to have it
20:31:14
dim
using (CL+SSL:MAKE-CONTEXT :disabled-protocols nil :verify-mode CL+SSL:+SSL-VERIFY-NONE+) in (CL+SSL:WITH-GLOBAL-CONTEXT (ssl-context :auto-free-p t) (pomo:connect ...)) doesn't fix it :/
20:31:36
shka_
anamorphic: CL is really cool for bit fiddling indeed, with ldb, dpb, logcount and other stuff in between
20:33:08
sjl_
the four missing log* ones are boole-1/2/clr/set which are all too trivial to deserve their own log* counterparts, I guess
20:50:54
dim
I'm not seeing anyway to fix that pesky SSL problem... I enjoy CL but sometimes I entertain thoughts of moving to a platform where I'm not alone with my difficulties, or just don't have them because someone else needed them fixed and it's been done already (not saying that racket or guile might be such platforms)
20:53:58
jcowan
I did that a few weeks ago, and it was fun at first but eventually a monstrous weariness of spirit came over me
20:55:25
jmercouris
I've read "LET creates its own lexical context within the lexical context of the enclosing function"
20:57:32
astalla
It is a special operator, the evaluator and the compiler treat it specially. But yes, at the core you can imagine it as a function application.
20:59:11
jmercouris
and if we are to reimplement let ourselves, we'd have to use anonymous functions as closures?
20:59:31
astalla
No, it does not. It is special-cased by the compiler/evaluator. But conceptually, it works as if it were a function application - without the overhead.
21:01:07
pjb
dim: the solution is to prepare a chain of certificate up to the CA, and to specify it to cl+ssl so it can do the verification. Disabling the verifications defeats the purpose of using SSL!
21:01:28
jmercouris
Bike: a function that is enclosed by another, does it have access to the parent functions variables?
21:03:31
pjb
dim: here is an example of a script building a chain with some specific certificates; adapt it to your needs: https://github.com/informatimago/test/blob/master/ias-ecc/build-chaine2
21:06:09
jmercouris
and now I am trying to make something like with-result* and I can't figure out how to do it
21:08:58
Bike
(with-result* ((a (foo)) (b (bar a))) (baz b)) => (with-result (a (foo)) (with-result (b (bar a)) (baz b)))?
21:13:11
anamorphic
jmercouris: there is a book called Lisp in Small Pieces that will give you a better idea of implementation of lexical scope
21:49:49
dim
on my laptop it seems to be /etc/ssl/cert.pem, on this pgloader user's debian system there are 456 files in /etc/ssl/certs, and I need to fix the problem for any pgloader's user, now and future
21:50:10
dim
it need to just work, as works psql and many other apps just by default, without having me to do anything system specific each time
21:50:45
dim
it seems to always come at a surprise here that someone would ship software written in CL to users who know nothing about CL, sometimes I'm thinking I'm doing it wrong :/
21:53:03
dim
are we still talking about that programming language with a standard fixed in the 90s? it could be funny if it wasn't 2018 already
21:54:09
dim
now there's https://github.com/thusoy/postgres-mitm/blob/master/postgres_get_server_cert.py that apparently knows how to retrieve the cert rigth from a live connection/socket, but I'm not sure what to do with that
21:57:35
dim
anamorphic: pgloader, it's on github, it does many things related to loading data in PostgreSQL, including full database migrations
21:59:28
dim
it's less often that I tell it, and I still love the parts when I say that I searched for a modern programming language after having lost patience in the Python 2/3 situation ;-)
22:01:45
dim
it stops being funny when you're the only one who can't establish a secure connection in between a given client and server both having openssl available in the OS, believe me
22:03:05
dim
if I search for “postgresql X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY” 2 of the first page of answers on google are pgloader issues
22:03:09
anamorphic
Yeah I have postgres running here - maybe if you can post a lisp paste (?) Can try it out
22:04:19
dim
you can first do the following in your shell: psql postgres://localhost:5432/dbname?sslmode=require to see it working
22:12:59
anamorphic
dim: OK psql postgres://localhost:5432/template1 -U postgres sslmode=require sees to work
22:13:29
anamorphic
dim: do you happen to have a convienient postmodern code snippet handy? I've not used postmodern before
22:14:19
dim
oh, if I set cl+ssl:*make-ssl-client-stream-verify-default* to nil then it connects on the laptop it seems
22:14:40
dim
because otherwise it's like it still requires even if in the context you ask it not to... for reasons
22:16:43
dim
so as pjb said of course that breaks the whole idea of being secure, to a large extend, so it should not be the default
22:19:19
fiddlerwoaroof
minion: memo for schweers: this is probably entirely too late, but I wrote some code to allow defining anonymous generic functions that illustrates adding methods to a generic function https://github.com/fiddlerwoaroof/fwoar.lisputils/blob/master/glambda.lisp#L32
22:19:44
fiddlerwoaroof
I'm not sure if it's great code, and it's entirely undocumented since it was mostly a quick hack, but it did work.
22:20:23
anamorphic
dim: Well today I learned that postmodern has a lovely API. Previously I used CL-SQL
22:22:01
pjb
dim: I don't find any ssl stuff with my postgres installation; perhaps it uses openssl, and you'd have to look where openssl seeks the systemwide chain by default. Otherwise have a look at the documentation or sources; I'd guess you'll have to reproduce the code searching for that file in lisp…
22:26:16
dim
what PostgreSQL does is call SSL_set_verify(conn->ssl, SSL_VERIFY_PEER, verify_cb), that's it, so the rest lies in OpenSSL itself
22:28:26
dim
or I can expose the setting (cl+ssl:*make-ssl-client-stream-verify-default* nil) to the end user so that when then get CA failure they may choose to disable cert verification altogether
22:33:28
anamorphic
Was wondering if related to https://github.com/cl-plus-ssl/cl-plus-ssl/issues/54
22:34:06
dim
fiddlerwoaroof: my audience is people that know nothing about CL, restart isn't the right approach here, even though I love that they exist
22:35:16
fiddlerwoaroof
Well, you could use handler-bind to say something like "SSL Certificate Verification failed, retry with verification disabled?"
22:36:20
dim
it still feels wrong on many levels, but at least would render pgloader usable in some cases rather than none
22:36:47
fiddlerwoaroof
I dunno, I think it's pretty standard to use this sort of pattern in common lisp
22:37:20
fiddlerwoaroof
low level code signals a condition, libraries add recovery methods via restarts and your toplevel handles conditions and invokes the appropriate recovery method
22:39:05
pjb
housel: strace is not enough, it may have an algorithm looking in some data structure before trying to syscall.
22:41:36
pjb
Don't disable ssl verification. Teach people on how to install certificates, and make it easy to do.
22:43:34
dim
pjb: you're saying that as if you knew how to make it happen. any specific advice how to make it easy for CL on machines you're never supposed to log in?
22:57:29
dim
and now after like a dozen builds, I randomly get The alien function "CRYPTO_num_locks" is undefined.
22:59:15
dim
(oh ok I had removed a patch to src/hooks.lisp that fixes that problem on debian, but not sure if it's helpful on other OSes)
22:59:23
anamorphic
Man it sucks that you're running into probs... Is this one a matter of email cl+ssl maintainer, hey updated the .so.N version?
23:00:12
copec
What is the typical license for open projects that this community has gravitated towards?
23:03:47
pjb
dim: well, yes it may be difficult to know for random machines. That's why applications are bundled with their own certificate chains.
23:04:17
p_l
pjb: well, linux systems using openssl have somewhat standard location for "Web-friendly" list of CAs
23:04:39
pjb
dim: if you linked with libcrypto, check that the symbol is present in it. Otherwise, you may need a different version of openssl.
23:05:31
p_l
dim: best would be if system default store (on typical linux system, it's in /etc/ssl, is used
23:05:41
dim
pjb: this one is a classic of CL+SSL when used in an image that you restart, you need to (cl+ssl:reload) for reasons
23:34:11
jasom
So I was looking at low-hanging fruit on the benchmark game, and noticed that OCaml was desetroying sbcl on the binary-trees test (this is essentially a GC/allocation test). I peeked at the code, and it was forking a new process for each parallel task, thus *greatly* reducing the peak heap size for any process. Applying the same change to sbcl got a 3x speedup
23:36:52
jasom
no-defun-allowed: this is within the parameters of the benchmark; the liveness is defined for each item, and this does not change that
23:37:10
jasom
aeth: I thought inline assembly was no longer allowed (they changed the rules a bit in the past couple years)
23:39:14
aeth
jasom: https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/mandelbrot-sbcl-1.html
23:40:38
aeth
Are libraries allowed? Because if there are you can't really avoid define-vop because some libraries can use it to provide a fast path for SBCL
23:42:48
Odin-
I mean, if there was, shouldn't there also be a rule against using optimisation directives?
23:43:13
aeth
Anyway, no matter what the rules are, what you wind up with is... basically... programs micro-optimized to the extent that you'll never, ever see in the wild, except maybe in a BLAS+LAPACK implementation or something (and *that* in itself might itself be gaming benchmarks in a sense because LAPACK is afaik often used to benchmark)
23:53:29
asdf_asdf_asdf
Hi. Did in Common Lisp are events? I want use: (event-control-left 25), but in Lisp not have events. In JS is: addEventListener?
23:56:09
asdf_asdf_asdf
I want in console CMD in Windows move (shift) letter "a" about 10 position in right for example.
0:02:12
Odin-
I don't think that name is usually used, but in JavaScript the term fundamentally means using callbacks from a central control loop.
0:02:57
fiddlerwoaroof
asdf_asdf_asdf: we probably need more context, but if you want an event loop there are libraries like cl-async
0:03:20
Odin-
I'm not quite sure what that has to do with Windows' console interface, but I haven't dealt with that ... ever, so that may be my ignorance talking.
0:03:32
fiddlerwoaroof
However, I suspect that you're misunderstanding how output in common lisp works
0:04:07
fiddlerwoaroof
By default, it's not like the browser where you position your words in a two-dimensional space.
0:04:34
fiddlerwoaroof
It's like a typewriter: every call to (format) or (princ) or related functions starts where the last one left off
0:05:25
fiddlerwoaroof
There are things like cl-charms that give a more webpage-like behavior, if that's what you want
0:08:07
asdf_asdf_asdf
OK. How shift letter "a" 10px position in right not using this: (defun a() (princ " ") (princ " ") ... (princ "a"))?
0:10:37
Odin-
And I think CMD.COM has some pretty drastic differences from the VT100-derived interfaces common in the Unix world.
0:12:37
asdf_asdf_asdf
I have windows console. And ... I want put letter "a" into position x,y. E.g. x=50, y = 100 using Common Lisp. Probably simple script.
0:14:52
p_l
to do it "right" you would need to read about Windows Console API, then link to it using FFI and call appropriate functions
0:14:54
Odin-
Well ... I don't know what the situation is on Windows, but doing that kind of thing portably is infamously tricky.
0:15:23
p_l
(cl-charms can actually do it for you when coupled with windows-capable ncurses library iirc)
0:20:49
asdf_asdf_asdf
Thanks, so how call function API cmd.exe using Common Lisp. I not want use external packages and libraries. I want standard package Common LIsp. I use SBCL.
0:20:52
Odin-
asdf_asdf_asdf: One thing to remember about writing JavaScript in the browser is that it has an astonishingly extensive support library for doing stuff with the web, far in excess of what comes with any other programming language.
0:27:00
fiddlerwoaroof
asdf_asdf_asdf: Common Lisp (and python, etc.) aren't really designed to make that easy
0:27:35
fiddlerwoaroof
Does the windows console support pixel offsets? or is it just a grid of characters?
0:28:51
asdf_asdf_asdf
Probably grid of characters. So i want call window and put letter "a" on position x, y. How do?
0:29:18
Odin-
The console probably doesn't, but it wouldn't surprise me if they still had DOS-era escapes to CGA and EGA modes...
0:30:23
fiddlerwoaroof
asdf_asdf_asdf: one thing you can do is, if the screen size is 80x25, print out 2000 characters with the desired characters in the right places
0:31:14
fiddlerwoaroof
What sort of program are you trying to write, though? This question sounds like you're trying to solve some problem that you aren't telling us about
0:34:06
asdf_asdf_asdf
OK. I want offset letter "a" for example 10px in right. In JavaScript i would write this: document.addEventListener('keydown', function () { myobj.style.left = pos+'px'; }, false);.
0:37:14
White_Flame
for terminal output, you can look at VT codes, ANSI codes, platform-specific cursor commands, a ncurses library, etc
0:37:32
White_Flame
all of it is basically sending out magic characters that the terminal interprets
0:38:28
White_Flame
but in most cases, you're plotting characters at the cursor, and moving the cursor. There is no active scene graph like what the browser supports in the DOM