libera/#commonlisp - IRC Chatlog
Search
21:22:33
White_Flame
when a customer wants a program to do X, and just wants it invoked by whatever their devops does, regardless of language implemented
1:04:16
cpli
how do i include trivial-features in my project such that i can `error` on certain trivial features?
3:13:22
loke[m]
@cpli:libera.chat: you just add it to the dependencies in the asd file, or am I miunderstanding the question?
4:00:05
jmercouris
are you trying to actually literally call something from the trivial features system in your asd?
4:12:35
bitblit1
<jmercouris> "are you trying to actually..." <- I think that is what he was trying to do.
4:13:29
jmercouris
then you have a couple of options, basically you can require it, embed it in the top of your asd and use it
6:28:34
bitblit1
So, I asked about compiling your program while it's running to see "live reload". I understand now that anything in the loop with it's own compilation unit will be able to reload while the application is running. However, how will I update things that should NOT be in the loop. Such as init functions. Let's say I am working on creating a game or whatever, I want to write the code to create a window and compile it while the program is running
6:28:34
bitblit1
and want to see it update live. However, putting the CREATE-WINDOW function in the main loop will create too many windows. I don't know how to get around this problem. Do I have to check if it is the first instance of the loop? If so, when I compile, will the loop rerun making it the first iteration of the loop?
6:35:02
bitblit1
Or the loop which runs and keeps checking for any events that might have to be processed
6:55:30
beach
If your application starts by executing some initialization code and then runs an application event loop or command loop, then if you want to alter the initialization code, it is very likely that you need to restart the application.
6:55:31
beach
You could execute additional initialization code at the REPL, like to create a window, but it would be complicated to make your application take it into account. You would have to think hard about how to structure your application in order for it to take such modifications into account.
6:57:14
beach
In other words, you can't have an application with some arbitrary structure and then expect it to respond to arbitrary code modifications at the REPL. You have to think about the modifications you might want and structure your application accordingly.
7:00:17
bitblit1
beach: Yes, so I understand most of the implementation and structure now. For example, I could create a render method which could look at a list of windows and keep on rendering/updating them. This is great as I could have an empty list and it would render nothing. Now all I have to do is change the window list, however, to do that, I would need to be able to access it easily, through a global variable. If i want to avoid global variables, I
7:00:17
bitblit1
would have to create a state class which would keep track of my state and update that. Is this correct? And if so, is it even a good idea?
7:02:16
beach
Sure. For instance in a CLIM application, the "application frame" is meant to hold "global" information about the application. At some point, though, you need at least one global variable, and in a CLIM application, this is CLIM:*APPLICATION-FRAME*.
7:03:45
bitblit1
Ooooh, this seems interesting. Thanks for all the info beach. Are there any pitfalls or caveats in this process?
7:07:12
bitblit1
What is this <CLASS> naming convention, don't see it much, is it good practice or smth?
7:24:19
loke[m]
<beach> "It is not a Common Lisp conventi..." <- I thought it was clever, until I had to deal with code that used that convention. Then I changed my mind.
7:26:16
loke[m]
I think it's Fukamachi that likes that style. He also uses one-package-per-file, which is also highly annoying.
7:27:34
loke[m]
I would of course like to clarify: That's my personal opinion. And the annoyance stemmed from me porting over code written in the package/file style to a single package and it was frustrating. I'm sure if you're used to the style and committed to it, it's not so annoying.
7:35:15
bitblit1
Yeah I used to use that convention but was like eh, package.lisp + using popular (non?)convention feels good
7:36:13
jackdaniel
bitblit1: if you have some "render" loop and you want to change the function that draws it, you may define a function update-window that is called from within that loop like (funcall 'update-window window), then if you redefine update-window then the new version will be used in said loop
7:36:35
jackdaniel
in contrary to (loop (draw-a) (draw-b)) where ou'd need to actually stop the loop to redefine its body
7:38:07
jackdaniel
in /some/ projects I have a macro define-class that defines a class, a function of the same name (being de-facto make-instance) and a variable with a value being the class itself
7:38:11
loke[m]
I also decided that it didn't really increase readability, so it felt similar to hungarian notation to me, which is something I don't like.
7:39:12
jackdaniel
bitblit1: you may find this interesting: http://turtleware.eu/posts/Tixel-Viewer.html
7:40:00
jackdaniel
of course the most important convention is to stick to the style in the codebase, otherwise it is a matter of taste (I like the convention <foo> personally)
7:41:00
loke[m]
That's a much worse take, because special and nonspecial variables have the same namespace.
7:41:04
jackdaniel
to deliberely hide the difference in the client code; I'm not sold on that though
7:42:08
jackdaniel
the program in this post also allows redefinitions: http://turtleware.eu/posts/Controlling-the-terminal.html
7:42:55
loke[m]
jackdaniel: I think anyone who's done any elisp programming knows how annoying it is when dynamic variables are not marked up.
7:43:28
jackdaniel
some languages other than common lisp even make up separate accessors for special variables (so they do not share the same namespace)
7:46:47
bitblit1
It's crazy how you guys do this for free and to help people out, inspires others to do the same, growing the community. Can't go without appreciation.
7:48:27
jackdaniel
don't worry, soon this boring detail will be abstracted away by chatbots - they'll consume the content someone created and answer any question you want
7:58:36
bitblit1
Why can I create an instance of tmp-class and have the state be set to 'single-float?
7:59:14
jackdaniel
the type is your propomise to the compiler, some implementations ignore it, some enforce it on adequate optimize values
7:59:58
bitblit1
Oh... so like what should I do if I want to make sure the types in my classes are right?
8:00:21
beach
bitblit1: I believe recent versions of SBCL will check this if you have a high value of some OPTIMIZE qualities.
8:00:28
jackdaniel
also thanks(?) to the fact that classes can be redefined (so the type declaration may actually change), the compiler can't make assumptions about slot types at compilation time - even if it knows what is the class of the argument
8:01:25
jackdaniel
but then keep in mind that NIL is not of the type cons, so if you want to allow default NIL value, then the type should be (or null (cons integer))
8:02:38
beach
bitblit1: I strongly recommend you change the default OPTIMIZE settings of SBCL, at least during development.
8:04:50
bitblit1
Oh, I understand so if we want to finally publish a high performance library we can just (declare (optimize 3))?
8:05:43
cpli
if i only require `open` and `close` (posix) i feel as though there should be some simple posix library; i.e. not osicat
8:05:45
beach
bitblit1: I find that the choice of algorithms and data structure is way more important for performance than the OPTIMIZE settings, so I don't bother with such declarations.
8:09:11
beach
bitblit1: From #clschool I have also observed that many newbies are concerned about low-level optimization, including things like (SPEED 3), but those are often the same newbies that have insufficient knowledge about the design of algorithms and data structures. So they have highly micro-optimized, yet slow, code.
8:12:22
bitblit1
IDK why I am dragging on this but one edge case I found was that the :type being (or null (cons integer)) is that only the first element (or cons cell) has to be an integer, and the rest can be anything they want. Is this intended?
8:14:33
beach
The thing you can't do is to specify a list of arbitrary length with a particular element type. Other than is you use SATISFIES of course.
8:15:52
bitblit1
Huh? Ooooooh lore expands. You mean using an array. Dunno I don't need that level of detail just a list of windows or integers
8:16:52
beach
In that case, if you really want to check the type, use SATISFIES. Speed for that kind of thing doesn't matter.
8:17:36
beach
Also, you would probably define abstractions like ADD-WINDOW so that you don't have to use the concrete data type all over your code.
8:26:44
bitblit1
There are already many functions like add-window create-window etc. Although I haven't :USE XLIB, Isn't it kinda wrong to do that
8:29:04
beach
It is usually not that good. And by not :USEing it, you can create your own ADD-WINDOW function with a name in your own package.
8:30:21
beach
bitblit1: I highly recommend you think of the objects you manipulate as part of a (usually CLOS) protocol so that you do not litter your code with concrete representations.
8:30:55
beach
Establish the types (usually classes) and operations (usually generic functions) used to manipulate your objects.
8:41:26
phoe
what would be an elegant to say "return true if all these elements are EQUAL to one another" in CL?
8:48:06
splittist
which is every 'equal, but making a choice about what to do with no or one element.