freenode/#lisp - IRC Chatlog
Search
6:49:24
jack_rabbit
It must also check if it's actually bound, too, yes? Or can I not set RECURSIVEP to t if I'm not already in a call to read?
6:51:12
beach
jack_rabbit: No, RECURSIVE-P is a lexical argument to READ, so it is not accessible to you.
6:51:33
phoe
"If recursive-p is true, the call to read is expected to be made from within some function that itself has been called from read or from a similar input function, rather than from the top level. "
6:51:35
beach
jack_rabbit: Just like if you do (defun f (x) ...) you can't set X unless you are inside the call to F.
6:51:56
jack_rabbit
So I would assume I cannot set RECURSIVE-P if I'm not already in a call to READ.
6:52:22
beach
jack_rabbit: But you are never "in a call to READ" unless you edit the code of the READ function
6:54:04
beach
jack_rabbit: The only code that can assign to the variable RECURSIVE-P is the code inside the READ function, just like my F and X example.
6:54:44
jack_rabbit
beach, by "set RECURSIVE-P" I mean call read with argument RECURSIVE-P equal to t.
6:55:33
beach
jack_rabbit: You can always pass whatever value you want for RECURSIVE-P to your call to READ.
6:55:35
phoe
you can all MACROEXPAND, for example, which does not require #'READ to be on the stack anywhere.
6:57:53
beach
Like I said, nothing prevents you from calling READ yourself with RECURSIVE-P equal to a true value.
7:00:02
beach
"If recursive-p is true, the call to read is expected to be made from within some function that itself has been called from read or from a similar input function, rather than from the top level. "
7:00:40
phoe
Therefore it might be UB if there is no non-recursive READ on the stack but you call a recursive READ.
7:00:54
beach
So I take that to mean "the consequences are undefined if READ is called with RECURSIVE-P being true at the top level".
7:04:45
beach
jack_rabbit: Passing a value as an argument to a function ESTABLISHES A BINDING for the corresponding parameter. Establishing a binding for a variable is a very different process from that of SETTING the value of a variable.
7:05:36
jack_rabbit
beach, I am not confused about that. Again, I interpreted phoe's statements as a convenient shorthand for what we were talking about.
7:05:47
yggdrasil_core
so, has anyone here gotten renderdoc to work with a common lisp program using cl-opengl in sbcl?
7:07:42
yggdrasil_core
I figure it's a streatch but I can't get the two to work together and it is making debugging my texture loading hard
7:08:17
phoe
yggdrasil_core: just a random thought, people over at #lispgames might have more experience with OpenGL in CL
7:09:51
phoe
It's hard to figure out general cases like getting X to work on Y, and easier to figure out why error X happens with stacktrace Y.
7:10:50
yggdrasil_core
when I set it up to run the binary it just either doesn't open it, or it immediately closes, when I inject into the process it just doesn't capture anything
7:12:54
yggdrasil_core
I use save-lisp-and-die to produce the binary, which does work just fine when ran outside of renderdoc
7:16:08
yggdrasil_core
unless you mean to see how far it is getting when renderdoc starts it (if it is actually starting it)
7:17:01
yggdrasil_core
I'm not, but thats because in this particular case I don't think there is an error happening :p
7:17:58
yggdrasil_core
I'm submitting texture data and having problems with it being loaded right, because I am not sure what pngload is giving me ._.
7:27:54
yggdrasil_core
was it the one that posts a bunch of square characters and then highlights everyone in the channel?
8:26:47
jackdaniel
first advice: state the program goal in question or in comments in snippet, I don't know what kind of advice do you expect
8:27:31
jackdaniel
fourth advice: don't put main program in toplevel, define function for it (and eventually call it toplevel)
8:36:41
jackdaniel
if you don't need macros don't use them (this is a rule of a thumb, when you known what you are doing you may bend this rule of course)
8:37:01
minion
asdfjkla: have a look at pcl: pcl-book: "Practical Common Lisp", an introduction to Common Lisp by Peter Seibel, available at http://www.gigamonkeys.com/book/ and in dead-tree form from Apress (as of 11 April 2005).
8:44:03
jackdaniel
asdfjkla: start with making these variables arguments for your function, not globals
8:55:30
jackdaniel
since current-word is result of computation on word and guesses, you may have (Defun hangman (word guesses) (let ((current-word (current-matches word guesses))) …))
10:35:06
beach
I started working on rules for indenting Common Lisp code. Here is a first version of what I came up with: http://metamodular.com/indentation.pdf
10:40:11
beach
For a multi-line string, the beginning of the string would be indented as usual, and the rest of it, just left alone.
10:40:36
beach
Comments are part of the parse result, so in the case of ;; they are indented with the code.
10:42:45
phoe
if a function accepts &key args then slime seems to figure it out and indent accordingly.
10:42:54
beach
flip214: Pairs like that are not a problem. The rules only compute the indentation of the first parse result on the line.
10:43:43
phoe
beach: I suggest that you include that. &key args are pretty important to indent properly because they tend to come aplenty at times.
10:44:17
phoe
Also I suggest that you spend a little bit of time on indenting macro lambda lists, too.
10:45:26
phoe
Since most Lisp forms are function/macro/specop calls, and these have their lambda lists and lambda lists keywords.
10:50:51
phoe
The moment your editor has utilities for paren matching and ability to do general indentation, then it has the two utilities required for sane Lisp writing.
10:51:22
Colleen
About trivial-indent https://shinmera.github.io/trivial-indent#about_trivial-indent
10:57:29
flip214
beach: yeah, but I meant that if you can derive that the arguments are pairs (or, generally, N-tuples ;),
10:58:04
flip214
you could have the second part of the pair (or the later parts of the tuple) indented one level deeper
11:10:42
flip214
or, if they are on the same line, it would be nice to have the non-first-tuple-parts aligned, too.
11:12:06
flip214
but first part aligned, second aligned, and two spaces min to signify the separation is my favourite style
11:19:16
beach
flip214: Ah, yes, I see what you mean. Either way, may standard macros would have their own rules, so I am not worried about SETF.
11:45:41
jmercouris
Can someone explain to me why my top syntax is invalid? https://gist.github.com/b0a5cb982df032cf381d2795d9ff6750
11:45:56
jmercouris
Why is it an issue to have specialized arguments as the non-first arguments in a defmethod?
11:49:19
Maerj
jmercouris: yes pls, eg reorganising, style, other constructs eg macros that may help, etc, I am new to lisp
11:49:40
jmercouris
I don't see a lot of people using setq, I think normally you'd do a definition of some var as a top level form and setf it
11:54:06
jmercouris
It looks pretty alright though, kind of hard to read through at first glance I thought "play" would be the main loop, then I scrolled down and it was "hangman"
12:02:26
jmercouris
I would say your program is sufficiently simple where it is not really necessary
12:14:46
attila_lendvai
it doesn't depend on the length so much as on readability. look at macros as a thin layer of syntax sugar. i.e. you should implement most of the functionality as functions, and if the syntax of that API is cumbersome (e.g. you need to create many (lambda () ...) wrappers), *then* create a thin layer of macro(s) that smoothen out the syntax
12:47:19
Xach
porky11: there is more than one way. i think the easiest is with the easy-handler system. But a file response is mostly the same as any other response - you load the data from the file and send it as the response.
12:47:20
porky11
I have set something to "image" instead of "text/html" and just read the file char by char and write it into a string
12:48:03
Xach
porky11: When I was faced with a similar issue, I used a dedicated server for images (nginx) because it is more efficient.
14:08:34
dim
depending on the project I like have a self-contained lisp image that embeds all the static resources (css, js, html, images) and serve from memory, and then for efficiency you can add nginx/varnish in front of hunchentoot
14:09:21
dim
see https://github.com/dimitri/pgcharts/blob/master/src/utils/cache.lisp for the hunchentoot implementation of serving files content from memory
14:10:41
dim
https://github.com/dimitri/pgcharts/blob/master/src/resources.lisp is the other file that you might want to have a look at
14:13:05
dim
the ability to deploy a single binary file that is self-contained, even for web based projects, is still something that I really like
14:58:02
jmercouris
Shinmera: when evaluating trivial-indent:define-indentation, I should be able to just M-q and it will use that new indentation right?
15:23:55
Shinmera
jmercouris: Also check if slime notes something in the minibuffer when you indent. It'll say something about an invalid structure if the indentation hint is malformed.
15:24:17
jmercouris
Interestingly enough, I was taking the default form for a defun, and applying it
15:24:42
jmercouris
though, I don't think this is an issue with trivial indent, but somehow with emacs, or my lisp installation
15:25:40
jmercouris
Just simply this: (trivial-indent:define-indentation defcommand (4 &lambda &body))
15:31:43
jmercouris
but no change when I run: (trivial-indent:define-indentation defcommand (10 &lambda &body))
15:37:53
jmercouris
Don't bring logical solutions into this discussion, I was just lighting up the torches
15:38:46
jmercouris
Shinmera: Yeah, it really is, the macro indents properly on other people's computers
15:41:51
killerstorm
Hi, is anybody interested in a tiny gig, paid in cryptocurrency? I need a parser for a certain language. Might be like a hour of work if you have experience with parsing.
15:42:38
killerstorm
Here's an example of input and expected result: https://gist.github.com/killerstorm/6f125482f50fba847763f42ead365f7b
15:46:14
jmercouris
Shinmera: emacs -q indents properly, seems like it is time to painfully comb through my emacs config
15:47:00
dlowe
killerstorm: are libraries allowed? Using a parser generator library like esrap would make it pretty easy.
15:48:03
killerstorm
dlowe: DSL for blockchain application programming. I'd love to use Lisp but custom syntax probably looks more impressive.
15:48:25
Shinmera
It looks troubling enough because that snippet doesn't even come close to properly defining the syntax.
15:49:34
killerstorm
Hey guys thanks for your advice but I already have DSL in Lisp. I want to try DSL which is not Lisp. For commercial reasons.
15:49:44
dim
a self-contained micro-service, either in a binary image or a container or something...
15:52:02
dlowe
killerstorm: https://github.com/dlowe-net/orcabot/blob/master/src/calc.lisp has some sample esrap code
15:52:07
Shinmera
If sample code is all you want here's an example grammar implementation for GLSL, which is C-like. https://github.com/Shirakumo/glsl-toolkit/blob/master/grammar.lisp
16:15:07
killerstorm
dlowe: Thx for example. Does esrap generate some nice error messages? Or at least a point where error happens...
16:16:28
killerstorm
My offer stands, by the way. I'm short on time and would rather save myself a bit of effort.
16:17:36
dlowe
killerstorm: good error messages are hard - the usual way is to write more grammar rules that cover the entire input space that generate errors.
16:20:50
killerstorm
Well currently I have Lisp-base DSL which doesn't even point to a line of code where error happened. So I guess anything would be an improvement...
16:23:55
jmercouris
probably not that much, as there is not many "legacy" lisp projects that require maintenance
16:24:17
beach
dim: Oh, yes, you would know, right? At least judging from your stories from your domain.
16:25:22
dim
C is ok, because it's meant to run within PostgreSQL code space and PostgreSQL is a very old C program (20+ years) so it comes with all the high-level abstractions you actually need
16:25:38
beach
jmercouris: I.e. people spending way more energy using a language that is not adapted to their problem just in order to avoid learning and using Lisp.
16:26:07
dim
other than that, most of the stories I follow are where people are re-inventing SQL in their application language
16:26:55
dim
I'm not sure about Lisp itself apart from re-inventing it poorly in so called “modern” programming languages, and with what I could achieve with pgloader on my free time, I'd rather do CL
16:29:47
jmercouris
beach: Ah okay, yeah, that would be interesting to know indeed, I'm sure it happens quite often as lisp is "intimidating"
16:30:08
jmercouris
I guess it would be akin to learning a non-latin language, not necessarily more complex, just unfamiliar, and that is why it scares users
16:31:16
dim
learning Common Lisp means questioning some of the things you took for granted and some of the well-known trivia such as “lisp is old and useless”, “there are no libs in lisp”, “you can't do XXX in lisp”, etc
16:31:48
jmercouris
speed is definitely an issue in python, which amazes me, as so many people spend their time on a single implementation
16:32:10
dim
and then when you get to it you're like what? how come there are so many control operators, what is this OO model, handler-bind and restart-value what? packages are only about symbols? what's a system? etc
16:32:15
jmercouris
I was having GIL problems in so many of my projects, now you might say "you are the weakest link", and sure, maybe I am :P
16:32:49
dim
so I can't blame people for not wanting to put in the effort, unless they just don't feel like it for the wrong reasons without having had a curious look first
16:33:01
jmercouris
dim: Yes, there were lots of times where I THOUGHT I knew, but didn't, and still all the time as I am learning new lisp I am having to "relearn" concpets
16:33:30
jmercouris
It is hard decision to make because learning lisp basically will not put food on the table for you, with any degree of ease another language will
16:34:25
beach
dim: True, one can't blame the lone programmer for not wanting to invest in a new language with unknown benefits. But one CAN (and I DO) blame project leaders in industry who don't even bother doing the math to see whether Common Lisp would be a better choice for their projects and products.
16:35:53
beach
I think at this point, I could just have a few abbreviations, one for each rant, and most #lisp participants would know what I mean.
16:36:22
dim
beach: we used to have the same rant in the PostgreSQL community, and it boils down to “you're never going to be fired for using XXX”, with XXX being IBM, then Microsoft, then Java, then many other things, but PostgreSQL and Common-Lisp kind of never made it to the list
16:36:47
dim
so rather than complaining about that beach (which I do too), how to we have Common Lisp enter that “never going to be fired for picking it” list?
16:49:32
dim
maybe we should build some important piece of infrastructure in common lisp and have it flexible and very reliable and have people depend on it
16:50:56
dim
that's how C and Unix got there I think, and Go with docker and the family around it nowadays, and Python I'm not sure it's just because it was easy to hack code in the language I guess; Java got a lot of infra project I believe, nowadays maybe Kafka and Zookeeper would be on the top list?
16:51:36
dim
Erlang has RabbitMQ and people hate it but still run it because it does the job, mostly, and in a good enough fashion and not too much competition in this space I presume
16:52:15
dim
what's a good Common Lisp “infrastructure” project that non-CL people could rely on in their production architecture, and discover later that it's actually been developped in CL, to a great benefits
16:53:18
beach
Not really. I do several things in parallel. Editor, debugger, GUI library, compiler, etc.
16:54:28
jmercouris
you could also increase common lisp traction by writing a popular tool in it, you know, like a browser ;)
16:54:48
beach
dim: I have done some applications in the past. And I do want to make better versions of some of them. In particular Gsharp which is an editor for standard music notation.
16:56:55
beach
jmercouris: Yes, McCLIM was a result of my needing a pure Common Lisp GUI library for Gsharp.
16:58:10
dim
that's quite nice! I think I've looked at Gsharp and found it cool in the past, but as a guitar player well, chords and tabs :/
16:58:52
dim
anyway, Gsharp and McCLIM or a browser or pgloader even won't be a crucial part of a production infrastructure that people would deploy without feeling like they need to be able to hack the product
16:59:37
jmercouris
there is yet another question to ask though, does popular support mean a better future for CL?
17:00:06
dim
Kafka, Varnish, Docker, PostgreSQL of course, Memcache, Redis, etc are examples of what I mean by infra-with-an-api
17:00:09
jmercouris
on one hand, python has a ton of users, but what has that done for python? some machine learning bindings?
17:00:54
jmercouris
dim: I guess you could write yet another provisioning system like salt, chef etc
17:01:15
jmercouris
and it could use sexp to represent the state of the system instead of awkward yaml files
17:01:35
dim
I'm thinking maybe a non-ACID memory database system with a producer/consumer mechanism would be good
17:01:50
beach
dim: I don't think Common Lisp will ever be on that list of yours. But I think one can hope for some highly-educated project leaders in industry understanding that Common Lisp might be a better choice for some of their projects. For that to be the case, I think we need much better programming tools.
17:01:58
dim
the thing that sits in the middle of the infra and allow the other pieces to seamlessly work independantly
17:02:34
dim
beach: I understand your position, I don't think that's the best option/leverage we can have, though
17:03:05
beach
dim: Maybe not. But that's the domain where I feel I have the competence to pitch in.
17:04:23
beach
Also, in order to put in as much work as possible, I need to justify it as research, and this domain fits well with that goal.
17:04:47
dim
that's a PostgreSQL “proxy” that implements the PostgreSQL protocol and does some connection pooling / admission control, but it doesn't know how to support prepared statements and people who've been trying to add that feature failed, because the C code is intricate to work with
17:06:38
dim
(also pgbouncer is 1-core only by design, with event-loop based processing, and when doing lots of traffic that's a bottleneck)
17:06:55
Xach
I was hoping to write a configurable DNS server so I could do some dynamic DNS without much hassle
17:08:05
Xach
I have many of the pieces to make what I want, though. I wrote a packet parser long ago.
17:08:39
Xach
Oh, I am not looking for a packaged solution, but a project that would be a fun hobby and result in something useful to me :)
17:09:57
dim
etcd & zookeeper and the like are used to register alternative resource providers (web servers, db servers, you name it) and guarantee that a single provider is elected at all time, and allows to then connect to the current “leader” easily ; I don't think they handle DNS changes when a new leader is elected
17:48:02
Shinmera
Other things that will automatically be highlighted are with-foo, check-foo, and do-foo.
17:50:25
Shinmera
The reason deffoo doesn't highlight is because def* is ambiguous. Consider stuff like default.
17:51:03
jmercouris
I see the ambiguity, but if I have my system and macros loaded, emacs should be aware of them
18:01:39
kini
dumb question - I'm looking at some code containing (load "foo.lisp"), and I'd like to add a form after that LOAD which looks like (setq bar:baz 'xyzzy), but the bar package is defined in foo.lisp so the function containing the LOAD fails to compile because package bar doesn't exist (at compile time). How do I get around this? Or is it not possible?
18:03:22
jmercouris
having said that, this feels like an x-y problem, can you please describe on a high level what the situation is?
18:05:04
Xach
kini: one common workaround involves using read-from-string, but it's something to avoid, usually
18:07:11
kini
Er, I don't quite follow -- both the existing LOAD and the SETQ I'm trying to add are inside a function body, not at the top level. (Or maybe that's not what you meant?)
18:07:11
kini
The situation: I have a program whose purpose is to figure out the dependencies of a quicklisp package; it does this by installing quicklisp in a tempdir, pulling in the package, and looking to see what else gets pulled in. To do this, it LOADs quicklisp's setup.lisp at runtime. I'm trying to make it work behind a proxy by setting ql-http:*proxy-url* right after that setup.lisp is loaded.
18:07:22
kini
I should add that I really don't know much about common lisp :) I don't know what a system is for example...
18:07:57
dlowe
kini: we call them systems instead of packages because the word "package" already meant something in CL
18:08:37
jmercouris
shka: I can't conjure a situation in which it makes sense, but there must be one :D
18:09:13
kini
I'm not trying to write the logic for quicklisp dependency detection or anything, just trying to one-line hack this existing program so that it will work behind a proxy :)
18:09:49
Xach
kini: you can (setf (ql-config:config-value "proxy-url") <something>) and it will remember it between sessions.
18:10:17
kini
remembering stuff between sessions probably won't work because this program runs in a sandbox
18:10:38
kini
jmercouris: not sure what you mean by "incorrectly" -- I have it in all the traditional environment variables, if you mean
18:11:18
jmercouris
kini: I was imagining a machine where you've setup a proxy because somehow the quicklisp servers are inaccessible in your country or something, I misunderstood the situation, my apologies
18:13:51
kini
if you're curious about the code I'm looking at, it's here: https://github.com/NixOS/nixpkgs/blob/8818546d/pkgs/development/lisp-modules/quicklisp-to-nix/quicklisp-bootstrap.lisp#L56
18:20:29
jmercouris
and let's say that as soon as (a) is invoked, in between the invokation and the actual printing, *some-global* is changed somewhere else, perhaps in another thread
18:21:28
jmercouris
it was a setf at first, and then I changed it to print without removing the string
18:43:44
_death
jmercouris: if it's a special variable, it's likely the implementation has per-thread storage for it
18:44:50
jmercouris
_death: Maybe this is a stupid question, but is the lambda of a function body a closure?
18:46:35
jackdaniel
funciton body is a function body. function may be a closure, if it closes over some variables
18:46:47
_death
jmercouris: if it's the global binding, then there's a race condition, and you could use synchronization primitives