From: Cyrus H. <ch...@bo...> - 2006-02-16 04:31:39
|
I've been attempting to use with-alien, now that antifuchs kindly pointed out that the problem with my sb-alien forms wasn't with the forms themselves, but rather with trying to compile them and that I need to load them directly. Back to with-alien... I'm of the opinion that the default stack-allocation for make-alien is a mistake. I'd like to see a more lispy memory model in which an alien variable is allocated and when gc'ed automatically frees the memory it was allocated, allowing with-alien vars to be used in a closure, or otherwise kept around. The current behavior could be achieved with a :stack or :dynamic-extent storage option. Of course in order not to break existing code, we could default to that and add a :heap storage option that would be as I've described. On a related note, why does make-alien warn about doing runtime- allocation? That's why I have called the function in the first place! I totally appreciate SBCL's chatty compiler, but I think we should try to increase the signal-to-noise ratio by making it shut up where appropriate. It's quite possible that I'm off base here, and that through the right combinations of declarations this can go away, but I don't want to have to resort to muffling warnings if I can help it. Thanks, Cyrus |
From: Alexey D. <ade...@ma...> - 2006-02-16 19:36:33
|
Hello, Cyrus Harmon <ch...@bo...> writes: > why does make-alien warn about doing runtime- > allocation? That's why I have called the function in the first place! It may issue a note about run-time allocation of an ALIEN wrapper around the malloced memory; if you store the result into an alien container, or pass it to an alien function, there will be no notes: (defun foo (x) (declare (type (alien (* (* int))) x)) (setf (deref x) (make-alien int)) nil) -- Regards, Alexey Dejneka "Alas, the spheres of truth are less transparent than those of illusion." -- L.E.J. Brouwer |
From: Nikodemus S. <nik...@ra...> - 2006-02-28 05:40:19
|
Cyrus Harmon <ch...@bo...> writes: > I've been attempting to use with-alien, now that antifuchs kindly > pointed out that the problem with my sb-alien forms wasn't with the > forms themselves, but rather with trying to compile them and that I > need to load them directly. ...which is a bug. Last I tried to figure out what was going on I decided that the issue is if not due to, then at least compounded by the ability of WITH-ALIEN to create _lexical_ types. IIRC most of the confusing bits involved there are to handle things like (WITH-ALIEN ((FOO (STRUCT BAR (X INT) (Y INT)))) ...) and could go away if we required a toplevel DEFINE-ALIEN-TYPE for BAR beforehand, and only accepted a bare (STRUCT BAR) or BAR as the type in WITH-ALIEN. ...or maybe I remember wrongly. Just a thought. > Back to with-alien... I'm of the opinion > that the default stack-allocation for make-alien is a mistake. I'd > like to see a more lispy memory model in which an alien variable is > allocated and when gc'ed automatically frees the memory it was > allocated, allowing with-alien vars to be used in a closure, or > otherwise kept around. The current behavior could be achieved with a > :stack or :dynamic-extent storage option. Of course in order not to > break existing code, we could default to that and add a :heap storage > option that would be as I've described. I agree. > On a related note, why does make-alien warn about doing runtime- > allocation? That's why I have called the function in the first place! MAKE-ALIEN is actually a macro. The note isn't so much about the implied malloc, but about constructing the whole support structure on the lisp-side of things, which is slow as molasses in this respect. This compiler note is really one of the important ones, and implies a huge slowdown. Shutting the note down is sometimes trivial and sometimes seemingly impossible -- but I _think_ it should always be possible as long as you actually know the types involved at compile-time. ...but I don't claim I've always managed to silence them, so... Cheers, -- Nikodemus Schemer: "Buddha is small, clean, and serious." Lispnik: "Buddha is big, has hairy armpits, and laughs." |