freenode/#lisp - IRC Chatlog
Search
18:50:51
pjb
(let ((sequence #(0 1 2 3 128 129 130 254 255))) (format nil "~{~2,'0X~}" (coerce sequence 'list))) #| --> "00010203808182FEFF" |# ; sorry, missed a ~
19:45:06
tempate
Hello. I'm reading Practical Common Lisp and I am kind of stuck. For some reason https://bpaste.net/show/6a504c25c54d isn't working as it should. When running (test+-) I should be getting T if all tests are passed. Instead, it's just returning nil every time.
19:46:59
tempate
Also, for some other reason, when compiling the first time (fyi, using Portacle) I get 1 Error 1 Warning and 3 Style-warnings. But, when compiling for the second time, it all works out just fine.
19:57:56
tempate
the thing is I don't know where I've gone wrong, as much of the code is just copied from the book
20:01:51
tempate
_death: yes, it's that section I just finished reading and updating the code, which is the one I send
20:02:26
shka_
so they have java, C++ and go, i suspect that C++ would be rewritten if not for the size of the code base
20:06:45
_death
tempate: there are many sites for programming "challenges".. lisp specific ones are http://www.ic.unicamp.br/~meidanis/courses/mc336/2006s2/funcional/L-99_Ninety-Nine_Lisp_Problems.html and https://github.com/google/lisp-koans I guess
20:07:38
_death
tempate: books like ANSI Common Lisp, Paradigms of AI Programming, Structure and Interpretation of Computer Programs also have exercises
20:08:28
tempate
Fade: I've checked that one already, but the problems require a level which I don't yet have
20:44:06
fe[nl]ix
git reset origin/master, then use Magit or something similar to split the changes in 3-5 commits
21:14:38
phoe
fe[nl]ix: though, honestly, I do not know how to organize these commits within these 3-5 ones - I literally completely reorganize the code in there.
21:22:21
phoe
a macro generates code. the compiler that compiles a function must know what kind of code it contains in order to compile it.
21:22:58
phoe
so, if the compiler encounters a function that contains a macro call, that macro must be defined right during that moment of compilations (unlike functions, which may be defined later).
21:23:45
tempate
but if a function is not calling a certain macro, it doesn't matter if it's defined before or after, right?
21:24:41
aeth
Afaik, defmacros and defuns are generally mixed, unlike globals/constants, which should go at the top by convention.
21:24:50
phoe
if a function doesn't use a macro, then it doesn't care if or when that macro is defined
21:25:51
phoe
as for when macros/functions should be defined in the code: anywhere as long as it's logical
21:26:22
tempate
ok. I wasn't sure if it was good practice to define macros before all else or not. That sorts it out, thanks
21:42:44
_death
also define the functions that a macro uses before use of the macro.. one way to do it cleanly is to separate macro definition from use, for example by placing them in different files
21:45:37
aeth
Usually, I wrap the functions in eval-when until they get too long. After a few hundred or so, then a separate file becomes the clear answer.
21:47:37
aeth
The options are (a) put the functions in a separate file or (b) wrap the functions in eval-when. This is only necessary for functions called *while the macro is expanding*, not called in the final expansion result. i.e. (defmacro foobar () (foo 42)) requires this workaround but (defmcaro foobar () `(foo 42)) does not.
21:50:03
aeth
These functions usually return lists acting as Lisp syntax. e.g. (foo 42) in the first example might return `(make-array 42 :element-type 'single-float :initial-element 0) but (foo 42) in the second example if doing the same functionality shouldn't do that because it's being called at runtime.
23:25:30
no-defun-allowed
i had a go at abusing the CL printer to print LLVM IR, but it's a bit tricky
0:06:00
aeth
Oh, good, the next Fedora (30) will have a more recent version of SBCL. For some reason, Fedora fell 1-2 cycles behind and is on an ancient SBCL. I understand why Fedora wouldn't upgrade within a release because SBCL can be backwards-incompatible, but Fedora's still on 1.4.6. in Fedora 28 and Fedora 29. https://apps.fedoraproject.org/packages/sbcl/builds/
0:06:26
aeth
Strangely, that builds page makes it look like they might release 1.4.14 for the current versions (28 and 29) as well.
0:08:02
aeth
I wonder if there's an implementations matrix for the major Linux distros, as in which implementations and which versions are provided by each major distro.
0:12:14
skidd0
i'm trying to define a utility function that drops all my tables in a DB. The problem is that when I eval the (defun ..) to load it into my slime REPL, it evaluates the logic of the function and drops the tables
0:12:33
skidd0
i want to have the function defined and 'handy' so i can clear my tables as i'm developing them
0:13:05
aeth
Hmm... Fedora is currently at SBCL 1.4.6. Ubuntu seems to be on SBCL 1.4.10 and Debian stable is on 1.3.14 (!!!). SBCL for CentOS/RHEL can afaik be obtained through EPEL 7 and is at 1.4.0. Doing this for all major implementations and distros would give decent expectations about what to expect.
0:14:03
aeth
skidd0: Are you using a DEFUN directly or are you using some library's DEFINE-FOO macro?
0:14:32
aeth
skidd0: I don't think it's an eval-when, I think there's probably a macro you're using that has side effects at macro-expansion time... or something like that.
0:16:56
aeth
asarch: foo:bar is the symbol bar from the package foo. foo::bar is also the symbol bar from the package foo. The difference is that bar must be exported for foo:bar to work, but bar can be internal with foo::bar
0:17:56
aeth
I basically only use this :: because Lispers always forget to export the type of something
1:46:06
istofu
(global-set-key "\C-cc" (lambda () (interactive) (insert "/**/ ") (forward-char -3)))
1:46:39
istofu
So, i have that, but instead of me having to type out (n) being the value going between /**/ how do i set a var
1:51:26
p_l
asarch: GLUT is explicitly a C library, there's no "native" GLUT for CL and thus no CLIM relation
1:53:47
p_l
CLX btw is part of X11 "standard" itself, enough that it was part of the full set of X11 documentation (rarely seen in the wild, I need to rescue one...)
1:54:42
p_l
asarch: for libraries, CFFI is one option (portable). SWIG can help you sometimes in getting CFFI running
1:57:43
p_l
asarch: if you search for it, I think some people did bindings to GLUT compatible with cl-opengl :)
1:58:35
p_l
https://common-lisp.net/project/cl-opengl/ <-- probably not the most recent code, but a good start?
1:59:49
asarch
I though they used CLIM to "create" the windows and in those windows create the OpenGL layer to render scenes
2:00:28
p_l
unfortunately I don't know of any integration between CLIM and GL, except of mostly abandoned attempt at opengl driver for clim
2:03:48
p_l
I'm not sure if Symbolics 3D stuff moved to CLIM at some point (doubtful), but in both cases it had mostly-software renderer that would take bitmap area from the gui library for its own use
2:20:45
aeth
asarch: If you want CLIM on top of OpenGL, you would need cl-opengl with another library to handle input, such as cl-sdl2 and SDL2.
2:21:17
aeth
These types of applications also probably want to redefine what a 'window' is because in a 3D application you probably want fake windows in one fullscreen or large-window application rather than true OS windows.
2:21:47
aeth
So there would need to be a layer in between cl-opengl+cl-sdl2 (or similar libraries) and a CLIM implementation
2:23:09
aeth
If you wanted a full-CL approach (at least as fully as possible), you'd probably want to use cl-sdl2 because that's what nearly everyone uses with cl-opengl so it's the safest choice.
2:25:15
aeth
(Good alternatives include using a lower-level SDL2 wrapper, or reimplementing the functionality of something like SDL2 and writing 3 backends for each of the major desktop OSes)
2:26:52
aeth
No matter what the details, CLIM with OpenGL would probably target a simple OpenGL GUI system with fake in-window windows, etc. This afaik doesn't exist yet.
5:13:31
Demosthenex
hrm, https://bpaste.net/show/5a7df14bd379 the same version of swank that works on sbcl is failing on abcl