freenode/#lisp - IRC Chatlog
Search
8:57:51
beach
A Gray stream is a stream. It is named after David Gray, so it has nothing to do with the color.
8:58:51
jmercouris
so it is a protocol based on the implementation of some defmethods required to be considered "gray"
8:59:15
beach
Then the programmer defines methods on that class like trivial-gray-stream:read-char etc.
8:59:24
jmercouris
so it is one programmers specification of what functionality a stream object should support
8:59:52
jmercouris
and why might I want to conform to this protocol? are there supporting libraries that expect gray stream conforming objects?
8:59:53
beach
Yes, for example, you can write a stream that returns random characters and never reaches EOF.
9:00:33
beach
SBCL and probably most other Common Lisp implementations accept Gray streams as arguments for stream functions, like READ.
9:03:43
jmercouris
and I assume again it was probably a time/money issue that prevented its integration into the specification?
9:04:43
jmercouris
so what happens if you only implement part of the protocol, let's say you only implement the byte reading methods
9:05:26
jmercouris
for example, in places where SBCL allows gray streams, will it cause issues, or would it just try to work, and if a method doesn't exist- then raise a signal
9:06:46
jmercouris
I'm hoping that when I get to it in a Gentle introduction that I'll finally understand
9:07:11
beach
There are no signals in Common Lisp. The only "signal" in the Common Lisp HyperSpec is a verb.
9:09:18
jmercouris
by that same logic couldn't you say "this signal in this function produced a condition"?
9:09:39
beach
Here is an example of use of Gray streams: In Second Climacs, I nead to READ the contents of an editor buffer. But the buffer is not a stream. It has a complex structure. So I create a Gray stream that is acceptable as a stream to the Common Lisp implementation, and that knows about the structure of the buffer, so that it keeps the current line and column in its instance.
9:11:09
jmercouris
so when you say "the buffer is not a stream", you basically mean the buffer is not a contiguous block of data that can be easily read from?
9:11:49
jmercouris
and so you hide that complexity behind a stream object that knows from where to fetch the various parts that compose the buffer to make it appear as if it is one contiguous block, or a file or something, something that a normal stream could read
9:11:52
beach
Furthermore, in Second Climacs, I keep a cache of expressions already read, indexed by position. If a call to READ is made with such a position, I return the cached object, and advance the position beyond the characters of the object.
9:12:23
beach
jmercouris: I mean, it is not a stream in that it is not (typep <buffer> 'stream) so it can't be used to READ from.
9:12:52
jmercouris
okay, I see, it is some other, unsupported type, so you had to implement a gray stream to treat it as a stream
9:13:25
jmercouris
and why exactly might you want to do this? where did you need to read the buffer contents as a stream?
9:13:48
beach
jmercouris: The buffer contains Common Lisp code, and I need to read it in order to analyze it as such.
9:14:14
beach
If I hadn't done it this way, I would have to re-implement a specific READ function for this purpose.
9:14:42
jmercouris
right, and that function would read from the buffer, generate some strings or something, or a file, and pass them to READ
9:14:43
nirved
jmercouris: for conditions (and a lot of other topics) you might want to look in "Common Lisp Recipes"
9:16:39
jmercouris
so you don't need to understand what the database is or how it works, just that it supports some sort of protocol
9:27:25
jmercouris
I guess a pre-requisite would be good IMAP or POP3 support, which I understand, does not really exist?
9:32:09
pjb
jmercouris: you may have a lookt at examples of use of gray streams: com.informatimago.clext.pipe or flexi-stream.
9:33:10
pjb
jmercouris: no, to write a listserv, you need very little. You can hook it to an email address with an entry in the aliases file, and it can send back email using sendmail with run-program.
9:33:34
jmercouris
pjb: I am just wondering why mailman is such a massive program, there must be more to it somehow
9:34:02
pjb
jmercouris: no, you can wonder. C programs (or most other programming languages actually) are about 30 times more verbose than lisp.
9:34:48
pjb
jmercouris: they don't have memory management, error handling, generic functions, a dumb type system, etc, so there is a lot of code duplication.
9:40:43
pjb
beach: when I started programming 100% in CL, I translated my library (which was originally written in Modula-2, and later translated into C), into CL. And between the modules that were useless in CL, and the more concise code for the rest, I got that number.
9:43:50
pjb
Look for example openssl. For ASN.1 data structures, they have actually a single "generic" set of functions, but they have macros to generate wrappers for them, with the specific C types. So their man page have 30 functions for 1 feature! https://manpages.debian.org/testing/libssl-doc/d2i_ASN1_TYPE.3ssl.en.html
9:45:13
pjb
And then, they wonder why they are missing bugs… https://news.ycombinator.com/item?id=18236345
9:45:46
pjb
While the brain cells of the C programmers are busy handling errors, managing memory, and avoiding buffer overflow, they forget about sound software engineering rules and proper design. While the code of libssh looks cleaner than eg. FreeBSD, there are still quite a number of functions that are bigger than a screen height.
9:47:03
pjb
Twelve malicious python libraries found and removed from pypi <https://www.zdnet.com/article/twelve-malicious-python-libraries-found-and-removed-from-pypi/>
9:47:58
jmercouris
if you were to implement a listserv in CL with administration portal, what would it look like?
9:49:00
pjb
I would make a postgres database. Then there would be a program to receive the email and process commands or diffuse messages. And a hunchentoot program to manage the administration.
9:50:02
pjb
Since the "process commands" is actually just another interface to to the adminstration module, perhaps this could be a separate server (used by both the email processing and the hunchentoot), or you could merge all three in a single lisp image/unix process.
9:50:04
jmercouris
holycow: no problem :) it is my pleasure to work on it, I just hope to be able to do more
9:53:45
jmercouris
so if the system gets an email at mailman-admin it'll invoke /var/lib/mailman/mail/mailman with the args admin mailman?
9:53:50
pjb
jmercouris: an alternative would be to define a transport in postfix, so you could directly use a running server. With the alias, you would write a little program that would connect to the running server, if you don't want to launch a new program for each message.
9:56:23
jmercouris
because I know that mailman sucks, out of personal experience, and I just want something that just works with minimal configuration, hence why I was thinking of writing my own in CL
9:56:28
pjb
For example, you could implement a SMTP server (without the sophisticated options, it's quite simple). Then you can either hook it behind postfix, or directly on the internet if the machine is used only for your listserv. This would let you do fine filtering when receiving the enveloppe, even before receiving the message.
10:09:45
pjb
Actually, this is just a command system interface. You have different ways to give commands: by sending emails, thru the web, at the unix shell, perhaps thru irc, etc. So you just need a lisp REPL to receive the commands (using a lisp REPL allows you to script those commands too!), and to hook the various user interface to to the same REPL system.
10:11:10
pjb
There are a few algorithms you need to recover or reproduce from listserv or mailman, about the managing of addresses to avoid loops, process bounces (just a different command), etc.
12:31:13
pjb
holycow: if interested, you can implement it in CL. Have a look at https://www.informatimago.com/develop/lisp/com/informatimago/small-cl-pgms/sedit/index.html
16:13:14
flip214
any alexandria maintainers around to take a look at https://gitlab.common-lisp.net/alexandria/alexandria/merge_requests/7, please?
16:39:56
anamorphic
Do I need to wrap a defparameter in some kind of eval-when in order for it's binding to be seen from within a macro?
16:40:59
pjb
anamorphic: clhs defparameter says: If a defvar or defparameter form appears as a top level form, the compiler must recognize that the name has been proclaimed special. However, it must neither evaluate the initial-value form nor assign the dynamic variable named name at compile time.
16:44:16
anamorphic
Ah OK. So (eval-when (:load-toplevel :compile-toplevel? I'm not sure if I need :execute
16:46:20
pjb
But if you define it at compilation-time, compute the value at compilation time, perhaps it cannot work if you load only the source? Or perhaps you can also compute the value when just loading the source. Depends on your program.
16:47:12
pjb
For example, when you define functions to be used by macro, you usually don't need them at run-time (unless you plan to use the macro at the REPL, say). In that case, you can skip the :load-toplevel situation.
16:47:34
pjb
So the compilation-time function don't take space at run-time (unless you load the source of course).
16:47:57
pfdietz
If you use the macro in another file those functions better have been loaded, though.
16:49:34
pjb
It's true, that an implementation could fork a different compilation environment for each compile-file that is not within the same with-compilation-unit. Ie it could throw away compilation-time definitions :-)
16:50:02
pjb
In that case, loading the compiled files between compile-file would be essential, and you'd have to include :load-toplevel for those functions.
16:55:03
|3b|
if you skip loading the files you use in macros, you will probably eventually be annoyed when you try to fix something interactively that uses it :)
16:57:11
HighMemoryDaemon
Does a pathname (ex. #p"~/Documents") offer any benefits over a regular string? In Quickproject's make-project function, I noticed that regular strings work too.
16:59:33
|3b|
main place i can think of it would matter is things that try to guess intent from types, for example something that would interpret a string as input, and a pathname as name of file containing input
17:22:00
|3b|
: is just part of the symbol syntax in the reader, with no real name. #p and #' are reader macros
17:22:37
emaczen
What happens with the memory management of pointers (with CFFI) and multiple threads (with bordeaux-threads)?
17:22:45
|3b|
(specifically # is a dispatching reader macro, with p and ' being specific instances of that particular dispatching reader macro)
17:23:03
emaczen
For example, If I create a pointer on a thread, then use it in the main thread, where does it need to be freed?
17:24:31
|3b|
symbols (including the : or :: ) and numbers are built into the reader syntax though, so you can't really change how those are read without just parsing everything yourself
17:25:56
emaczen
anamorphic: but it doesn't explain why I seem to leak more memory with multiple threads then not
17:25:57
|3b|
scymtym: thanks, thought there probably was actually a name after i wrote that, but forgot to go look it up
17:28:12
|3b|
(and to clarify for original asker, #\ is another dispatching reader macro on # that reads a character, so #\: reads as the character : and in general that's how we'd talk about characters when talking about CL. i skipped them previously to try to simplify the answers)
17:33:38
pjb
That said, we could as well talk about the character "a": (character "a") #| --> #\a |# ;-)
18:13:11
HighMemoryDaemon
In my projectname.asd file, is there a good way to use a system that is in a folder of my project? Ex. 'pathnames-lib/pathnames.asd'. I could symlink it to my ~/common-lisp folder but I'd prefer not to.
18:25:26
HighMemoryDaemon
This is what I ended up going with. https://hastebin.com/mukebifepo.lisphttps://hastebin.com/mukebifepo.lisp . Of course I would have to follow the second half of that article if I end up needing to do something similar in a .lisp source file.
18:35:49
flip214
shka_: I guess you'll need a new slot metaclass.... or you re-use eg. the documentation slot (urgh)
18:37:59
Bike
https://github.com/clasp-developers/cl-jupyter-widgets-old/blob/master/src/iwidgets/widgets/traitlets.lisp here's one i wrote that adds observers and stuff. needs... direct/effective-slot-definition-class, compute-effective-slot-definition