freenode/#lisp - IRC Chatlog
Search
20:18:50
foojin
How can variable capture occur in the following example macro from "On Lisp": (defmacro cap2 (var) ‘(let ((x ...) (,var ...)) ...)) ?
20:20:38
foojin
It's not specified. I suppose that whatever's in there, it contains instances of ",var".
20:25:20
foojin
phoe: Wouldn't your example expand to nested LETs? BTW that's what I meant when I wrote about a "LET error".
20:30:03
foojin
So, if one were to suppose that only correct (non-malformed) expansions will occur, there's no way for x to be captured, is it?
20:32:24
shrdlu68
p_l: I've been thinking about the language-agnostic-syscalls thing, reading up on kernel hacking, procf, etc.
20:38:30
shrdlu68
Ah, so :cl-user :uses :sb-ext, which is why I've always been able to call gc without the sb-ext: prefix.
20:44:23
pjb
foojin: more precisely, it's because in (let ((x 42)) (cap2 x)) we want the x in (cap2 x) to refer to the x bound by let. but the macro cap2 could expand to (let ((x 33 #|for example|#)) '(list x)) #| --> (list 33) |# where is bound in the inner let. This is not inherently wrong. It's just a matter of specifications of the cap2 macro, and of general expectations ("style") in CL.
20:45:03
foojin
phoe: The question was somewhat ambiguous, with dots instead of actual code, so I assumed there were no comma substitutions there. Otherwise that situation would surely be possible.
20:45:44
pjb
foojin: If you are defining a specific DSL, perhaps it's meaningful for the x in (cap2 x) to be refering something else than outside bindings. But if not in this case, it's generally expected that the in a form such as (let ((x 42)) (cap2 x)) the x in (cap2 x) be a lexical reference to the lexical binding.
20:47:13
pjb
It's often better to let the user specify the name of the inner variables, when he can also provide bodies or expressions refering them: (let ((x 42)) (cap2 (x) x)) would then read similarly to (let ((x 42)) (let ((x 33)) x)) and there would be no contraried expectation: it would be clear, lexically, that cap2 establishes a new binding for x.
20:47:42
pjb
And if the user wants to use the outer x, this allows him to write (let ((x 42)) (cap2 (y) (+ x y))).
20:49:23
pjb
shrdlu68: I have this in my common.lisp rc file: (mapc (lambda (package) (unuse-package package "COMMON-LISP-USER")) (delete (find-package "COMMON-LISP") (copy-seq (package-use-list "COMMON-LISP-USER"))))
20:49:41
pjb
shrdlu68: so my CL-USER is the same in all implementations, and I can write conforming code even in CL-USER.
20:50:18
foojin
pjb: I totally forgot about the "expectations" thing. It would indeed be quite strange for an inserted binding to get in the way (as shown in your first example).
20:50:33
pjb
puchacz: (subseq (com.informatimago.common-lisp.cesarum.file:binary-file-contents "/etc/passwd") 0 10) #| --> #(35 35 10 35 32 85 115 101 114 32) |#
20:51:57
pjb
foojin: this is why it's not wrong per-se. It all depends on the specification of the macro. For example, anaphoric macros establish an implicit binding to IT.
20:54:15
phoe
If an external symbol of the COMMON-LISP package is not defined as a standardized function, macro, or special operator, it is allowed to lexically bind it as a function (e.g., with flet), to declare the ftype of that binding, and (in implementations which provide the ability to do so) to trace that binding.
20:57:30
pjb
This is a strong exception for the implementations, because the default rule is that implementations can define functions for those symbols. But then they cannot use directly those functions in macroexpansions, because that could be wrapped in a flet/labels that would shadow them…
20:58:53
phoe
because with the symbol UNSIGNED-BYTE being exported, that would mean that the symbol UNSIGNED-BYTE is now globally fbound.
20:59:15
phoe
And it must NOT be globally fbound because there is no standard function CL:UNSIGNED-BYTE in the standard.
21:00:17
pjb
but 11.1.2.1.2 pt. 2 is generally explained saying that implementations may do just that.
21:00:53
pjb
Notice that in the exception it's not said "if the exported symbol is fbound or not" but "if the expected symbol is DEFINED by the standard as a function."
21:01:37
pjb
file:// works too, such as file:///opt/local/share/doc/lisp/HyperSpec-7-0/HyperSpec/Body/m_ignore.htm
21:02:13
phoe
It's nonetheless weird for me that the standard would permit a thing like #'UNSIGNED-BYTE.
21:02:46
pjb
phoe: not really. This allows implementations to use functions to represent things such as types.
21:03:35
varjag
so M-x hyperspec-lookup works for me if i set the root to a web adress, but not with the local hyperspec repo
21:05:02
phoe
I wonder if it has any constrains about whether some of these symbols must/must not be bound/fbound/macrobound.
21:05:25
phoe
I mean, if the list of all fbound external CL symbols is not permitted to be extended by the implementation above the bare minimum.
21:56:41
Ukari
is (defstruct ship ..) must use a 'make-ship' to make a instance? Is there anything like (make-instance 'ship ) also works ?
21:58:45
Josh_2
Hmm I wonder when Fare is gonna come back, there is some questionable English on his site
22:12:04
pjb
Notice that since you're asking for number: (ldb (byte 32 0) (round (realpart #c(-3.0 0.0)))) #| --> 4294967293 |#
4:28:35
sunshavi
when the error happens when doing (ql:quickload :qt), in place on qmake You should do qmake-qt4
4:30:27
jackdaniel
can't you configure it with (say): https://wiki.archlinux.org/index.php/Qt#Default_Qt_toolkit
4:32:33
sunshavi
beach: McCLIM is available on arch?. Let me check. Which are the differences with sbcl?
4:32:53
jackdaniel
if you are in exploratory mood you may try also McCLIM (which doesn't rely on FFI). It is far less polished than Qt, but is something fun to learn
4:34:22
sunshavi
well. This is my first day on common-lisp. I am here trying to do a replacement for dbdesigner wich is not available for armv7 arch
4:34:49
jackdaniel
here are my two screencasts of McCLIM: https://www.youtube.com/watch?v=kfBmRsPRdGg ; https://www.youtube.com/watch?v=RBOrllTA-yc
4:34:57
jackdaniel
and generally: https://www.youtube.com/playlist?list=PLo0SIc8er5gBWZsq64n0dxeIa63jU6XTX
4:37:39
beach
sunshavi: If you go McCLIM, you will have way fewer problems with the Qt maintainers making incompatible changes, and you will be programming in Common Lisp as opposed to some strange combination of Common Lisp and some lesser programming language.
4:39:13
sunshavi
i have done some gtk, some wxwidgets, vlc moved from wxwidgets to Qt. Then I though Qt is the way to go. But I could be wrong
4:39:47
beach
sunshavi: On the other hand, as jackdaniel pointed out, McCLIM is less polished than Qt. But then, you will have jackdaniel to help you with McCLIM and to help fix possible problems in McCLIM.
4:40:35
hjek
sunshavi: depends what you're doing, I guess. CLIM is pretty cool in that it's extremely lispy, but it does require an X server so for cross-building it's not super nice. Then something like LTK is really neat. Or perhaps Qt.
4:40:40
beach
sunshavi: I am very biased. I am totally in favor of programming in Common Lisp as opposed to other languages.
4:41:34
sunshavi
well. I just have learn some basic emacs-lisp. On my more than 10 years tour using emacs. But never tried cL
4:43:03
beach
sunshavi: Lucky for you, as I understand it, #lisp is one of the friendliest channels around.
4:45:46
sunshavi
but today I needed dbdesigner on my arm-workstation. when not available i turned on my x220. But I would like to start creating something like dbdesigner on lisp.
4:49:59
hjek
so, probably alright for something about databases. (and probably not alright if it's something that needs to look native, or graphics heavy)
5:01:11
hjek
sunshavi: no gtk in mcclim. i think it's pure X. but also there is supposedly a Cocoa back end for OS X
5:30:09
sunshavi
i have done a couple of tutorials on CommonQt. a simple frame with just a title, and a frame with three widgets label, text, button
5:38:19
jackdaniel
but you may load clim-examples, go to drawing examples and you'll have a button to generate from drawings ps / pdf
6:57:34
beach
sunshavi: And, was it compiled with threads enabled? (I am just guessing here. Normally, those examples work)
7:16:20
hjek
jackdaniel: application-frame could make sense in postscript though. https://en.wikipedia.org/wiki/Display_PostScript
7:18:54
beach
sunshavi: I am way outside my comfort zone here, but you could check whether :sb-thread is a member of the *features* list.
7:21:12
beach
hjek: A typical application for the PostScript backend (and for the PDF backend as well) would be if you have something like Gsharp (and editor for music scores). The saved PostScript document should then be a printed version of the score. The document should not contain the buttons, the interactor pane, the scroll bars, etc.
7:32:33
beach
Ukari: You export whatever names you want to use from a different package, whether they be the name of the struct, the accessors, the constructors, whatever.
7:34:24
beach
sunshavi: Check with jackdaniel first. He is the maintainer of ECL, and of McCLIM, so he would know whether that is good advice or not.
7:35:18
Ukari
i defstruct a (defstruct iterable-object (value nil) (next nil :type function)), and export by (:export #:make-iterable-object #:iterable-object-next #:iterable-object-value)
7:36:07
beach
Ukari: The Common Lisp implementation can not decide for you what functionality you want to make available to client code.
7:37:20
beach
Ukari: Like I told you, in a typical application you definitely do not want to export the names of the accessors of all the slots. That would be contrary to good software-engineering practice. And, again, the Common Lisp implementation can not decide what kind of protocol you want to suggest to client code.
7:38:12
beach
Ukari: If it so happens that you are not applying any particular modularity concerns in this case, then unfortunately, you are the exception, and you then need to export everything.
7:40:32
fourier
about having to write a lot of manual "exports" for automatically generated functions
7:42:12
beach
fourier: Only in applications that do not respect the slightest software-engineering technique would one want to export the names of all the accessors, and even less so of the slot names.
7:42:17
fourier
yes it makes sense. "I want to export all readers of this class/struct" - it is the applied modularity.
7:42:34
beach
fourier: Common Lisp was not made for people that have absolutely no concern for basic modularity.
7:43:19
beach
fourier: If you find yourself wanting to export the names of all the readers of some class, then there is very likely something wrong with your abstraction.
7:46:15
beach
There could *occasionally* be a need for that, but not often. Therefore, having to export everything is an exceptional situation. For exceptional situations, you then have to deal with the additional work of manually exporting everything. It would not make sense to have a special mechanism in the language for that, because it is, well, exceptional.
7:46:45
fourier
you put it to separate package to avoid name collisions for trivial accessors like "name" "age" etc
7:49:45
beach
Of course. But if the struct is only used as an aggregation of stuff, it would typically be in the same package as the client code. The package boundary is more likely used to define an abstract protocol that is not concerned with how things are stored.
7:50:32
beach
And, again, because they are exceptional, there is no need for a specific mechanism for exporting everything.
7:51:11
beach
So, again, yes, you would then have to manually include all the names in the package definition. Big deal.
7:58:07
Ukari
beach's option is acceptable if treat defstruct into constructors-function and slot-function. but if treat defstruct as static defination of a struct and it need to be use somewhere just like class in java or struct in c header, i thought defstruct should be more combined than spearated into divided functions
8:04:40
puchacz
hi, can salza2:deflate-compressor be passed an argument so it uses "no compression"?
8:05:35
puchacz
I want to let a user download a bunch of media files bundled together, and they are compressed already, so there is no point of wasting CPU (if there is any significant waste) on trying to compress them
8:11:30
Ukari
i use '(make-iterable-object :value nil :next nil)' with the defination '(defstruct iterable-object (value nil) (next nil :type function))', but it tells me :next is a function type and couldn't be nil