freenode/#lisp - IRC Chatlog
Search
15:39:22
sjl
is https://github.com/nixeagle/cl-irc/blob/master/trunk/utility.lisp#L127-L130 a portable way to implement read-byte-no-hang?
15:40:10
pjb
Which is not to say that it will work as you want. But this is how you can implement it conformingly.
15:40:59
pjb
Notably, the description of LISTEN talks of characters, while input-stream is specified as a stream, not a character stream.
15:41:21
pjb
This is an inconsistency, or at least, an underspecification: it says nothing about bytes for binary streams.
15:41:57
pjb
It also talks of interactive streams. So it may be good for binary socket streams, but perhaps it always returns T for file streams.
15:44:16
sjl
Is there an SBCL-specific one? I could live with that, but I can't seem to find one in the manual.
15:48:04
sjl
Hmm, it makes a decent argument there that (listen binary-stream) should always return nil.
16:14:39
marioxcc
Hello. Is there some Common Lisp implementation that is suitable to call *from* C code?
16:15:02
marioxcc
SBCL does not seem to be (it can call C code, but apparently not be called from C code).
16:16:12
jackdaniel
in fact you may define callbacks in SBCL to as far as I remember (so they may be passed to C world)
16:17:29
marioxcc
Xach: I am considering contributing to gtk-gnutella. I think it would benefit from rewriting a part in Common Lisp (or another high level language).
16:18:28
jackdaniel
phoe: CFFI is "just" a portability layer, if implementation can't "do" callbacks neither cffi will be able to
16:19:44
jackdaniel
phoe: that is not correct either - implementation may be supported by cffi in various degree, so if you call defcallback from cffi it will simply error out
16:20:00
jackdaniel
I'm sure SBCL has it implemented in CFFI, but it doesn't make that statement true in principle
16:20:17
shka
I need to perform join or two, i was wondering if i can somehow neatly express that using Radiance data-model module.
16:20:44
Shinmera
The database interface is very minimal, and doesn't do joins because some DBs don't do joins.
16:21:39
Shinmera
If you need more capabilities, you're better off accessing a specific database like postgres directly.
16:22:09
Shinmera
Naturally you can also do joins and stuff in your application if you need to. There's tradeoffs for everything.
16:23:27
marioxcc
I want to rewrite a part of a C program in Common Lisp to make it more easily manipulatable. Is ECL my best option?
16:24:14
jackdaniel
I can't say if its your best, but it is a good option. you may even embed CL in your application to connect to it at runtime
16:24:17
shka
Shinmera: let's say that i only need one-to-one relationships, does this makes things slightly easier?
16:25:11
jackdaniel
what is the best option for you depends on various factors (and its not that all are technical - taste is an example of non-technical factor)
16:25:22
marioxcc
Shinmera: If I know correctly, CFFI serves to call C from a Common Lisp implementation, but not to call a Common Lisp implementation from C.
16:25:30
Colleen
shka: Macro database:query https://shirakumo.github.io/radiance#MACRO%20DATABASE%3AQUERY
16:26:16
Shinmera
marioxcc: It can create callbacks, which you can stuff into C variables and then call from C out.
16:26:21
jackdaniel
marioxcc: I don't know, just asserting its the best option wouldn't be smart on my side
16:27:15
jackdaniel
if you have any questions regarding ecl drop them on #ecl channel (less traffic)
16:27:43
Shinmera
shka: Joins are a pain point, I know. I've been thinking about adding a mechanism to it, but it would increase complexity of an implementation for the interface quite a bit.
16:42:03
Shinmera
https://github.com/Shirakumo/radiance-tutorial/blob/master/Part%208.md#how-do-i-change-the-implementation-of-an-interface
16:43:58
Shinmera
The configuration variables for i-postmodern are here: https://github.com/Shirakumo/radiance-contribs/tree/master/i-postmodern
16:46:58
Shinmera
The documentation about the available modules/implementations are a bit scarce, and I apologise for that
16:54:21
ahungry
When using Emacs+slime, is there a standard mechanism to redirect the REPL output to a different buffer? Ideally I would like to have a slime prompt for running interactive lisp, and a separate output buffer to display the results of what is run
16:57:02
rumbler31
and then run emacs auto-revert-tail-mode on that file and keep it open in another buffer
16:59:59
ahungry
Thanks rumbler31, so it seems doable, but not as simple as just setting a variable in Emacs to control it
17:00:26
ahungry
Maybe approaching in the opposite direction would be easier (make a brand new prompt window that on RET sends the current input line to the active slime session for evaluation)
17:05:30
ahungry
hm, a very quick test shows something like slime-eval-buffer would work reasonably well for this (overall i'm hoping to get lispy working well with the slime repl, and the output from the repl breaks it's paren matching counts)
17:06:58
PuercoPope
Xach: Do the quicklisp failure reports bail on the first error? I've submitted a couple of fixes to the projects listed but I want to know if having a different issue appearing after the first one was fixed is a possiblity
17:07:23
Xach
PuercoPope: yes, they do bail out - if there's an error, there's no easy way to continue to find more until the first is fixed.
17:09:07
PuercoPope
but linedit also uses asdf to call gcc when loading the system and I don't know if that will work or not
17:10:34
PuercoPope
Xach: haven't check yet, submitted it today. (Currently at $work). But the solution worked for the other system of nikodemus that depended on madeira port
17:11:11
Xach
PuercoPope: I suggest grabbing sbcl 1.4.3 and using (ql:quickload ... :verbose t) to see everything that has to be fixed
17:11:14
pjb
ahungry: I was just asking, because I have a solution, but it's not standardized. I just invented it myself.
17:29:23
khrbt
PuercoPope: Xach: I did this thing a while ago that removes gcc and .c files from linedit. https://github.com/nikodemus/linedit/pull/10
17:46:11
PuercoPope
khrbt: I think remembering trying that branch a couple of years ago. linedit is almost there as a portable decent REPL experience from the CLI
17:53:23
shka
to set config i need loaded module, to load module i need started radiance, to update config i need to restart it which i don't know how to do
17:56:58
khrbt
PuercoPope: yes. my copy of linedit is based on your branches and I can even load/compile it on ecl and cmucl. I haven't yet looked into what is involved in actually installing a repl.
18:00:01
Shinmera
When you previously loaded it, it was using macros from the lambdalite db implementation. Those expansions ended up in the FASL. When you switched implementations, the lambdalite package isn't there anymore, but ASDF isn't smart enough to pick up that you switched implementations
18:02:02
Shinmera
Well you most likely used the db:query macro, which compiles the query language to something else to make things not slow as hell.
18:10:51
shka
Shinmera: well, everything works i guess, tables has been created for user and profile
18:20:23
shka
phoe: btw, I will use ORM that comes with postmodern because i hate myself and you ;-)
18:30:45
khrbt
Xach: What would be the best way to improve the linedit situation? The GitHub version, especially PuercoPope's "fork" branch is in the best shape it seems.
18:30:47
shka
Shinmera: btw, how one should approach to extending information in users? I would simply add my own tables, use foreign key and call it awesome, but perhaps there is a better way to do so
18:31:51
Shinmera
shka: If all you need is to store a string on a user object, you can use user:field
19:13:39
jasom
most ORMs tend to be buggy ill-specified implementations of half of a real object store; 99% of the time SQL actually maps better to the problems I have
19:15:01
jasom
though I wouldn't mind a sexp sugar on top of SQL, since that's more aesthetically pleasing to me than wrapping a DSL with ""
19:35:54
jasom
rumbler31: a tool to let programmers stay in their OO bubble and pretend that SQL doesn't actually exist ;)
19:39:25
dim
the problem space of application code objects in memory and of the relational model are not compatible, specialize each of them, the mapping is bound to fail
19:39:52
dim
the only interesting ORM style would be to map query results to app objects, as each SQL query defines a new relation
19:40:21
dim
I've seen that to some extend in POMM (PHP) and I think JOOQ (Java) has something to that approach
19:40:28
sukaeto
jasom: re: sexp sugar on top of SQL, I've been relatively happy with https://github.com/fukamachi/sxql
19:40:39
dim
in general ORM try to map the database model with the application in-memory state, and that can't help anybody
19:41:13
sukaeto
it doesn't do some of the more complicated dialect specific stuff (namely Postgres' ON CONFLICT and common table expressions), but it's extensible so you could always add those things if you need them
19:42:56
dim
disclaimer: I wrote a book on SQL this summer to teach that to app developers, available at https://masteringpostgresql.com ; I am quite opinionated on the topic...
19:44:16
jasom
dim: does it include basics of RDB? I was unable to take the DB course at university because there was no room in the class, so I've mostly just learned by doing...
19:45:25
dim
jasom: I think it does, but that depends on the specifics of the curriculum you missed ; you can get a sample with the full ToC for free (in exchange of your email) on the website
19:47:03
jasom
I limped by using key-value stores for like a decade before actually learning any SQL
19:47:17
sukaeto
anyway, to add my (potentially uneducated) opinion on ORMs to the discussion: I agree that trying to automatically map "sets of facts about the world" into "sets of objects in memory" is a fundamentally flawed errand.
20:02:46
p_l
the problem with ORM is that it's associated with ActiveRecord pattern, which is popular but not the only way that falls under "ORM"
20:08:45
sukaeto
I mean, I've used ORMs as just a way to query the database in the language the ORM was written in vs. embedding strings of SQL - that is, each ORM object is just a record representing some relation in the database, and the business logic objects consume/query the ORM objects. That works out just fine.
20:10:06
sukaeto
I still think things like SxQL are nicer for "querying the database in your language". Just one benefit of Lisp over most everything else. :-)
20:12:46
p_l
some ORMs provide explicit access to relational aspect instead of trying to shoehorn shit into objects
21:00:18
fouric
anyone have any resources on function hotpatching in CL? i've found a few pages on stack overflow that just tell me the bare minimum (how to hotpatch a single function using Emacs+SLIME), but i'm interested in knowing more, such as "how does this work?" and "how can i make my code \"aware\" of said hotpatching (e.g. add hooks that fire off when a function is replaced so i can run code that updates state)?"
21:01:21
fouric
stack overflow gives me like 2 pages that tell me what i already know, and google gives me those same pages before beginning to omit either "lisp" or "hotpatch" from my query
21:03:39
phoe
And your own DEFUN can contain code to fire any callbacks you want and call CL:DEFUN as a part of its operation.
21:04:21
fouric
i was hoping that there would be something built-in, but i'm willing to write my own variant of DEFUN if need-be
21:05:01
Bike
for how it works, it's a somewhat obscure point of compilation semantics. If a function defined in one compilation unit refers to another function defined in the same unit, e.g. by a call or #', redefining the other function is undefined behavior.
21:05:17
phoe
you also need to use something like ASDF's WITH-UPGRADABILITY for the functions that you want to be able to always replace.
21:05:20
Bike
But you can explicitly force a lookup by using fdefinition, either explicitly or by e.g. (funcall 'foo ...)
21:06:21
phoe
as long as your functions are *not* inlined by the compiler, setting a new fdefinition instantly causes the whole image to pick up the new function.
21:06:54
phoe
like, when the function is newly called, it'll use the new definition. old calls won't magically start executing the new function if the old function is in the middle of being executed.
21:07:49
jasom
fouric: under the hood, functions are typically called via indirection, so there is a pointer to the code for a function. When you redefine it, you create new code then just update the pointer
21:08:19
jasom
fouric if you know assembly at all, just look at this output from sbcl: (disassemble (lambda () (declare (optimize (speed 3) (safety 0))) (quux)))
21:09:31
jasom
then all of the call stacks &c. are roots for the GC, so no old function definition will get garbage collected until it is no longer on anybody's call stack
21:11:53
fouric
Bike: if there isn't some single document on the internet, that's fine, i'll gladly come here for help
21:12:19
fouric
...i was just trying to see if there was something that i could go to instead of re-asking questions that have already been put here multiple times
21:12:24
Bike
I guess the overall way to think of it is, the image is the image. it has some bindings, like of functions and classes. you can alter the bindings at your whim. these are basic language semantics. With functions, the compiler is allowed to integrate definitions and skip bindings sometimes, so you have to be aware of those times to do redefinition
21:12:42
Bike
But everything else is fairly safe. except there's also threading and who knows what's going on there.
21:13:52
fouric
is that how function redefinition happens? your code is running in one thread, and the SLIME client in another, and said client updates the definition of FOO or whatever, which the "main" thread picks up on the next time FOO is called?
21:14:56
fouric
Bike: i'm just trying to learn stuff while enroaching of the time of more skilled (and therefore productive) people in here as little as possible
21:14:58
Bike
the semantics are actually defined in a single threaded environment, and implementations do try to be nice
21:16:13
rumbler31
also, I personally appreciate the dive into more complicated topics that I might not yet even know how to ask about
21:20:05
jasom
also the specification lists when functions can be redefined; if they are either declared notinline at all call points, or not referenced anywhere in the file in which they are defined then it's safe.
21:20:38
jasom
basically permission to inline is logically the same as permission to assume the function will never change
21:21:24
rumbler31
jasom: what do you man about "not referenced anywhere in the file in which they are defined"
21:26:33
jasom
rumbler31: logically speeking there are 3 states for inlining a function; lets call them: inline, notinline and default. The default is "may be inlined anywhere in the same file as the function definition"
21:27:22
jasom
so a file with (defun foo () ) (defun bar () (foo)) the call to foo in bar may be inlined, absent any other declarations
21:28:39
sjl
(declaim (inline foo)) (defun foo ...) (declaim (notinline foo)) makes foo inlineable but prevents any compiler macros
21:29:18
rumbler31
so without explicitly specifying notinline on foo when loading the file, given the default inline state, a conforming implementation will warn/error when foo is redefined?
21:30:40
rumbler31
then.. I guess I still don't know what you meant to say with your second sentence
21:30:47
jasom
rumbler31: the assumption is that you know what you are doing if you redefine functions unless something very obviously is wrong (it was declared inline, you have two definitions of the same function in the same file)
21:31:27
jasom
rumbler31: a conforming implementation is allowed to assume that a function defined in file X has a fixed definition for the entire body of file X.
21:32:04
rumbler31
what does fixed definition mean? s.t. re-invocations of defun are unspecified behavior?
21:33:07
jasom
rumbler31: in practice it usually just means that the redefinition won't take effect, but I suppose it could have safety implications if the type of the function were inferred (not sure if sbcl does this).
21:34:09
jasom
For the purposes of incremental development using C-c C-k will usually mean that all functions not declared inline will work right (since you recompile the entire file).
21:37:03
jasom
macros definitions are invoked when the macro is expanded. When compiling this is the same as compile time.
21:37:27
jasom
so if you change a macro, there is no magic that finds all places in which it was expanded and recompiles them.
21:37:50
jasom
you should use asdf if you want this to work (it tracks dependencies on a file-level basis)
21:40:01
rumbler31
so the part about macros not being re-evaluated I understand. I will ponder how that affects function redefinition
21:40:33
jasom
My point is everything I said up to that sentence refers only to redefining functions. If you redefine macros, then you need to think differently
21:46:49
aeth
jasom: Return type information isn't inferred unless the function is inline afaik, i.e. (defun foo () (the single-float 1f0)) (defun bar () (+ 1f0 (foo))) (disassemble #'bar)
21:49:02
aeth
You could probably wrap a the around the function call, which would get rid of the generic-+, but still do type checking because it still won't trust you not to redefine #'foo. You'd probably need sb-ext:truly-the in SBCL, and you'd need to *really* make sure your wrapper will never fail.
21:52:45
jasom
I assume changing foo to be (random 1.0) or some such will have a similar effect. but use a single-float specialized add
21:53:20
aeth
jasom: I think that it's not a type thing but a constant thing, though. I've had the same thing happen with macros that generate functions that return constant strings. If I changed those macros in SBCL, I would then get a runtime type error on the user of that generated function if the length of the generated string changed (because length is part of the type in Pascal-style strings)
21:53:25
jasom
yup. So sbcl does assume that function-types for functions that are not declared inline are fixed
21:54:08
aeth
jasom: yeah, but I think it's specifically an optimization for functions that are returning constants
21:54:36
jasom
because I get a FPU add instead of generic+ when I change it to return a random single-float
21:55:31
aeth
You are correct, I just tested that with (random 2f0) and I get ADDSS and it tests for '(single-float 0.0)
21:57:05
aeth
I don't get a warn when recompiling foo to return "hi" (rather than the file), I just get a runtime type error when calling bar
22:00:10
aeth
(well, it would warn about the return type of foo not being compatible with +, so my example isn't perfect)
22:01:05
aeth
This is interesting, though. It means that fewer, larger files aren't just a stylistic choice. It will potentially make the code more efficient, but at the cost of possibly causing issues with recompiling just an individual function rather than the file.
22:01:31
stylewarning
aeth this is well known about compiling things within the same compilation unit
22:02:02
jasom
asdf has with-upgradability at least partly because the entire thing gets put into a single .lisp file
22:05:06
Bike
with-compilation-unit should be usable to make more things optimize together, at least in theory. hell if i know whether sbcl does
22:25:37
aeth
with-compilation-unit would only be necessary to get file-like optimizations in the REPL, though, right?
22:26:44
aeth
pjb: Is removing the file boundary possible in a way that's compatible with ASDF? It might be useful as part of a build step for distributing a final executable.
22:27:08
pjb
You would need asdf support for with-compilation-unit. I don't remember if it's available or not.
22:28:07
pjb
Also, you raise a interesting question: can we always concatenate all the files of a project for distribution, without changing semantics, vs. a separate compilation.
22:28:43
pjb
Obviously, it's not possible in general: you would have to add eval-when to be able to compile the concatenated file.
23:24:00
drmeister
That’s what I assumed with-compilation-unit was for when I first encountered it. Optimize whole compilation units together
1:29:31
pfdietz
I'd say not hard, although there are some parts you don't want to do first. Restarts are a bit tricky.
1:35:11
pfdietz
Restarts are a way to resume after a condition (like, an error) is signaled, without unwinding the stack.